-
May 3rd, 2011, 01:53 AM
#1
C++ Classes: Which are the differences between 'struct' and 'class'?
Q: Which are the differences between struct and class?
A: In C++ programming language, there is no difference between classes defined by using struct or class keywords, except the default access to members and base classes.
- for struct the default access is public;
- for class the default access is private.
Examples
Code:
struct SFoo : Base
{
int m_foo;
void Foo();
};
is equivalent to
Code:
struct SFoo : public Base
{
public:
int m_foo;
void Foo();
};
Code:
class CFoo : Base
{
int m_foo;
void Foo();
};
is equivalent to
Code:
class CFoo : private Base
{
private:
int m_foo;
void Foo();
};
See also
Last edited by ovidiucucu; May 3rd, 2011 at 02:01 AM.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|