C++: it's good programing use functions on a struct?

ulaoulao

Controller Man
Staff member
The only difference from a stuck to a class is how it handles memory. Also the their default access level is public where classes are private. In C it is a necessity but c++ it is interchangeable with a class. Some use Structs for short structures rather then a class. If you are making a car you would want a glass but in that car you may have a seat and you can make 4 seats (structs) in it. This is a bit more readable some say. Though ultimately it is up to you in how you want to do it. It is perfectly OK to put a class in a class.

So in that, sure using functions in a struct is no different then a class.
 
Last edited:

cambalinho

New member
thank you so much for correct me...
i did the question because i started, on past, from Turbo Pascal and then Visual Basic... their structures don't accept functions... so i did the question ;)
i never knew that the C structures accepted functions.. thank you so much for all
 

GASIYAT

Banned
thank you so much for correct me...
i did the question because i started, on past, from Turbo Pascal and then Visual Basic... their structures don't accept functions... so i did the question ;)
i never knew that the C structures accepted functions. Tutuapp 9Apps ShowBox . thank you so much for all

This is a bit more readable some say. Though ultimately it is up to you in how you want to do it. It is perfectly OK to put a class in a class.

So in that, sure using functions in a struct is no different then a class.
 
Last edited:
Top