The only disadvantage I can think of is their size, especially if you are passing by value rather than reference. OTOH, unless you are programming for a tight embedded system memory is generally cheap and you can always pass by reference.
--- Edit ---
I just had to respond to jbtascam's comments about passing by reference.
The definition of passing by reference is the passing of a pointer whereas passing by value is passing the entire item. In C programming it is quite common to pass a pointer to a structure (aka. passing by reference) rather than passing the whole structure itself (aka. passing by value). The advantage, of course, is you only put the pointer value on the stack rather than the entire structure.
As for the C++ guys, you are right, and object is pretty much just a glorified structure and if you are using C++ you might as well take advantage of the OOP paradigm and use objects when possible.
2006-12-22 02:54:36
·
answer #1
·
answered by Anonymous
·
0⤊
0⤋
There is no disadvantage in structures if you going to compare it within the scope of C langauge..
may be you can term the inabilities of structures as its disadvantages.. structures are kind of clone brothers to objects in terms of allowing multiple data types to be help together under one memory stamp and which can instantiated like a variable being declared..offcourse structures are the way the programs internally communicate ( remember any win32 programming )..
Structures are an implementation and different from objects in the way they are handled and managed...so there is absolutely no disadvantage in using structures..And dont compare them with any thing else it is obselete..its exactly comparing which is best integer or string...they serve their own purpose..
2006-12-22 11:03:31
·
answer #2
·
answered by Nancy Maxilus 2
·
0⤊
0⤋
Offhand, I'm not aware of any disadvantage in C. They would be required to create linked lists and can be used in arrays. In C++, a class is preferred unless very simple, as you can protect the underlying data with the keywords private or protected and use accessor methods to retrieve or set the data when required. More importantly, the methods or functions that control the state of the data are part of the object when a class is used.
-- Glenn
2006-12-22 11:10:08
·
answer #3
·
answered by Glenn 1
·
0⤊
0⤋
In "C" programming, you can't pass structures by "reference." You can only pass pointers or the entire structure.
Is this question about "C++" or "C?" Structures have huge advantages over the standard data type in C, or we wouldn't use them.
They have NO advantages over classes in C++ (in fact, they are a subset of classes in general).
2006-12-22 11:03:17
·
answer #4
·
answered by jbtascam 5
·
0⤊
0⤋