0
what is the diffrance between structure and class?
3 Réponses
+ 3
Just one:
Structures have default access level as public. But classes have default access level as private.
Thus, in the following struct:
struct MyStruct
{
int code;
char choice;
};
The members code and choice are public, and are accessible in main, or any local function following this declaration.
But in a class:
class MyClass
{
int code;
char choice;
};
The members code and choice are private by default, and thus are inaccessible in main, or any local function following this declaration.
Of course, you may change these rules by using the access modifiers, but this is the default (when you don't use any).
+ 2
@~swim~
Hmm. Never noticed that. But why is this so?