Hello everybody:
i have a question, and it's about using a pointer (just one declared) pointing to a class that has a nested class, the example code is like this:
- class a_class{
-
int *a;
-
public:
-
class b_class{
-
int *b;
-
public:
-
b_class(){
-
b = new int;
-
*b = 3;}
-
};
-
};
i know dat with pointers inside a class i should create constructors, but let us just skip that part, because isn't part of the problem; so when i created a pointer to the main class called a_class was like this:
- a_class *ptr = new a_class;
and after i made something like this:
- a_class::b_class *ptr2 = new a_class::b_class;
so this will create a pointer for the b_class alone, but i want to know how to do in just one pointer, i mean in *ptr, work with the b_class, being in the public part in a_class and the elements of b_class having them in the private, like in the example that i wrote up, because i tried something like this:
and the same with
or
i don't know how to do it, i tried a lot of combinations and nothing, if anybody knows the answer please let me know, one more question, how it will be if b_class is nested in the private section of a_class, and a final one, where is use nesting in classes, in the public or private section, or depends of what i want??
thxs for all