Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: C++
Expertise: Beginner
Aug 21, 2001

Classes and Structs -- What's the Difference?

The keywords struct and class are almost interchangeable in C++. You can declare a struct that has member functions, constructors, destructor, base classes and so on as if it were a class. Likewise, it's possible to create a class that has only public data members. The only difference between a struct and a class is in the default access. By default, all the members of a struct are public whereas in a class, al the members are private. The same is true for the default inheritance type: a struct entails public inheritance by default whereas a class entails private inheritance. The struct keyword struct exists for the sake of backward compatibility with C.
Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date