What are the advantages of using C++ based Classes/Objects over using legacy C Structures for managing standard Data Structures like Linked List, Stack, Tree, Queue ..etc? Let me know if the question is not clear.
For one thing, in C++ you can use templates, which allows you to create generic collections and use them in a type-safe manner. I.e. you can have a list of strings, another list of ints and a third of YourClass objects, all backed by a single list implementation, and the compiler guarantees that you can't put a string into a list of ints.
In C you could only achieve this via void* pointers, and type safety would not be guaranteed by the compiler.
One big advantage is that it provides you performance guarantees. Also, the code is easier to maintain as it is standardized and any new member joining the team will be able to understand the code quickly.
Advantages of C++/OO data structures:
Natural grouping of data structure with methods that manipulate the structure.
Much more natural names for methods/functions dealing with the data-structure: e.g. push() and pop() rather than some artificial namespace-embedding function names.
Compiler-checked protection of data structures.
Inheritance - deal with any iterable sequence.
the main advantage is that the methods (the code) are together with the data.
c style:
linkedlist_append(linkedlist* list, void* element)
now compare to:
class LinkedList
{
LinkedList* Append(void* element);
}
or even
LinkedList* Append(T* element);
C++ data structures are provided by the STL (all the ones in your OP anyway). You can make yourself a std::map right away in any C++ compiler. In C, you'd have to write it yourself. In addition, the STL makes many guarantees like strong type safety, no memory leaks, and is often faster than home-rolled alternatives. In addition, in C++, you can write templated functions to take virtually any STL data structure and, say, iterate over it.
Basically, C++ will automate an incredibly large amount of work for you and guarantee that it works and works well. There's no advantage whatsoever to a C solution.
While you can add custom methods using just C, this is rather ugly and C++ provides a more elegant and natural way. In C++, you can use polymorphism and add a base class to your structures. In your example, all datastructures will probably support an add() and maybe a find() method. Therefore, you can write code which is independent of the underlying datastructure - you can change the implementation or even the used datastructure later, if desired. Additionally, e.g. a stack can be defined as a special list, therefore you can extend your list to be a stack (or queue) and thus you reduce redundancy in your code.
Also, C++ comes already with most useful datastructures in the standard library, which is well written, template based thus generic, and everywhere the same, thus portable.