Hi.
I have 2 Basic Questions.
One. What's difference between these codes?
1. char ch;
2. char[1] ch1;
3. char* chptr = &ch;
I know which is pointer and which is a regular variable.
Two. What's difference between nesting two class and deriving a class from another?
The first line initializes declares... a character. Indeed, I did mix up something, thanks filipe.
The second line is syntactically incorrect.
The third line creates a pointer to the memory the first character takes up.
As for the difference between inheritance and nesting... inheritance is a mechanism by which one can create a new class that extends and/or modifies a certain class's functionality and this AFAIK is always possible in C++. Nesting is when a class or struct is created in another in its definition, which may not always be possible.
You meant for the array to be ch1[1], otherwise you have two variables with the same name.
Anyway,
1. Just a single plain character. Accessed with ch
2. An array with a size of one, its single value accessed with ch1[0]
3. A pointer to ch. It's value contains the memory address of ch. Accessed with chptr, and the data it points to is accessed with (*chptr) (parentheses () are optional)