What circumstances would a class be required in a program?
also why do we use classes instead of structures? are they interchanable and are they more useful then structures
also why do we use classes instead of structures? are they interchanable and are they more useful then structures
The only difference between struct and class in C++ is default member visibilty. With structs members are public by default; with classes they are private.
O-O is about classes hiding data and only communicating via well defined intrfaces. So classes are better for this purpose (hide things until you deliberately make them visible).
structs (and classes, though this is not so common) can be used as C-style "plain old data", if you just want to stores values using built in types (no methods, etc.)
The only difference between struct and class in C++ is default member visibilty. With structs members are public by default; with classes they are private.
Not only it. The default access specifier in inheritance for structures is public, but for classes is private.