P
PSN
Hi all ,,
I have a complex class which inturn contains several classses and
subclasses .. can some one give me an easy method to access the deep
most member variables (explained in the example below) .. However, i
have a much complex class with asmany as 6-7 subclasses ...
Please note that the names of the classes are completely different from
one another .. so we cannot form a uniform struncture of their titles
...
class C {
public:
class a1
{
public:
class a11 {
public:
class aaaa {
public:
int a;
int
func_1(){return a;}
....
};
class bbbb {
public:
int b;
int
func_2(){return b;}
....
};
aaaa OBJaaaa;
bbbb OBJaaaa;
};
class b11 {
public:
class cccc{
public:
int a;
int
func_3(){return a;}
....
};
class dddd{
public:
int b;
int
func_4(){return b;}
....
};
cccc OBJcccc;
dddd OBJdddd;
};
a11 OBJaa;
b11 OBJbb;
}*ptrC;
currently i use the following method which is highly laborious and
error prone ..
switch(ptrC->WhichObjectInitialized())
{
case 0:
switch(ptrC->OBJaa.WhichObjectInitialized())
{
case 0:
return ptrC->OBJaa.OBJaaaa.func_1();
break;
case 1:
return ptrC->OBJaa.OBJbbbb.func_2();
break;
}
break;
case 1:
switch(ptrC->OBJbb.WhichObjectInitialized())
{
case 0:
return ptrC->OBJaa.OBJcccc.func_3();
break;
case 1:
return ptrC->OBJaa.OBJdddd.func_4();
break;
}
break;
}
any help is highly appriciated ..
prakash
I have a complex class which inturn contains several classses and
subclasses .. can some one give me an easy method to access the deep
most member variables (explained in the example below) .. However, i
have a much complex class with asmany as 6-7 subclasses ...
Please note that the names of the classes are completely different from
one another .. so we cannot form a uniform struncture of their titles
...
class C {
public:
class a1
{
public:
class a11 {
public:
class aaaa {
public:
int a;
int
func_1(){return a;}
....
};
class bbbb {
public:
int b;
int
func_2(){return b;}
....
};
aaaa OBJaaaa;
bbbb OBJaaaa;
};
class b11 {
public:
class cccc{
public:
int a;
int
func_3(){return a;}
....
};
class dddd{
public:
int b;
int
func_4(){return b;}
....
};
cccc OBJcccc;
dddd OBJdddd;
};
a11 OBJaa;
b11 OBJbb;
}*ptrC;
currently i use the following method which is highly laborious and
error prone ..
switch(ptrC->WhichObjectInitialized())
{
case 0:
switch(ptrC->OBJaa.WhichObjectInitialized())
{
case 0:
return ptrC->OBJaa.OBJaaaa.func_1();
break;
case 1:
return ptrC->OBJaa.OBJbbbb.func_2();
break;
}
break;
case 1:
switch(ptrC->OBJbb.WhichObjectInitialized())
{
case 0:
return ptrC->OBJaa.OBJcccc.func_3();
break;
case 1:
return ptrC->OBJaa.OBJdddd.func_4();
break;
}
break;
}
any help is highly appriciated ..
prakash