I'm a noob so maybe this is a dumb question, but i'm going to ask it anyways. What is the point of a structure? Isn't a structure just a class with all variables are public? Why not just use a class? Why are there two ways to do he exact same thing?
I'm a noob so maybe this is a dumb question, but i'm going to ask it anyways. What is the point of a structure? Isn't a structure just a class with all variables are public? Why not just use a class? Why are there two ways to do he exact same thing?
Class concept came with C++
Structure concept came from C
Maybe that's why there are two things to do the same.
I think you can do a lot more with Classes though.. i'm not sure.
maybe something to do with using different functions ...
In C the struct keyword is used to define a structure that only contains data or objects of another structure (which would simply be considered a user defined data type in this case).
C++ extended the struct keyword and gave it the same abilities as the class keyword, meaning that it could now have member functions encapsulated along with data, making it virtually the same as a class except for the default access permissions.
I was taught to continue to use struct as I would in C (Data only) and class when member functions are required.