What is the differece here?

Hi all,

What is the difference between

Class A
{
int a,b,c,d;
Class B;
};

and

Class A
{
Class B
{
int p,q,r,s;
};
};

Which of them is called as Nested class?

Thanks
Pavan.
1
2
3
4
5
Class A
 {
 int a,b,c,d;
 Class B;
 };


a,b,c,d are member variables of class A, I'm not sure what Class B does exactly in this example. Looks like a declaration, but I don't know.

1
2
3
4
5
6
7
Class A
 {
 Class B
 {
 int p,q,r,s;
 };
 };


Class B is a member of class A. p, q, r, s are member variables of class B

I'm fairly sure example 2 is an exampke of nested Classes.
"Like other members, a member class (often called a nested class) can be declared in the class itself
and defined later:"

this is an excerpt from Stroustrop:(. So, had to ask this. Im not sure now too.
If that's true then they're both nested classes, yea. I wasn't aware of this, but it makes sense.
Topic archived. No new replies allowed.