C++ structures
This is a follow up from an earlier post...didn't want to hijack it so started another.
In that post it was said that structs (C++) are the same as classes except that all members (methods and variables) are public. Does this mean that structs support instansiation/constructors/destructors/inhertience/polymorphism etc as classes do?
Yes. Also, they support private and protected access levels, but the default is public (unlike C++ classes, whose default access level is private).
Yes, I believe so. The ONLY difference is that classes default to private, and structs default to public.
The public/private defaults also apply to base classes:
struct Foo {};struct Bar {};struct Quux1 : Foo, private Bar {}; // Quux1 and Quux2class Quux2 : public Foo, Bar {}; // are identical.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement