What are the benefits of using C ++ based classes / objects using legacy C structures to manage standard data structures like Linked List, Stack, Tree, Queue..etc? Let me know if the question is not clear.
On the one hand, in C ++ you can use templates that allow you to create shared collections and use them in a safe manner. That is, you can have a list of strings, another int list and a third of objects YourClass, all backed up by a single list implementation, and the compiler ensures that you cannot put a string in an int list.
YourClass
In C, you could only achieve this with pointers void*, and the type of security was not guaranteed by the compiler.
void*
One of the benefits is that it provides performance guarantees. In addition, the code is easier to maintain because it is standardized, and any new member joining the team will be able to quickly understand the code.
++/OO:
, .
/, : . push() pop(), .
push()
pop()
.
- .
, () .
c style:
linkedlist_append(linkedlist* list, void* element)
:
class LinkedList { LinkedList* Append(void* element); }
LinkedList* Append(T* element);
++ STL ( OP). std:: map ++. C . , STL , , , . , ++ , STL , , .
, ++ , . C.
, C, , ++ . ++ . datastructures, , add() , , find(). , - . , , , ( ) , , .
, ++ , , , , , .
, , , . , . - , - . if , , .
Source: https://habr.com/ru/post/1749201/More articles:@key does not work in eclipse (Windows XP) - eclipseEntity Framework 4 executes stored procedures for an insert operation in the wrong order when a multilevel parent child relationship exists - entity-frameworkLast contact changed - androidExcellent Python class decorator and maximum recursion depth - pythonbuild and analyze without working in my project - iphone.NET Web Service - Unmanaged C dll call - c #Cannot find asp: text field in javascript - javascriptneed help with regex - regexThe correct way to protect a private API key when versioning a python application in a public git repository - pythonIf an expression extending beyond includes? - includeAll Articles