Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Simple access to embedded class objects

Reply
Thread Tools

Simple access to embedded class objects

 
 
PSN
Guest
Posts: n/a
 
      10-16-2006
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

 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      10-16-2006
PSN wrote:
> 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 ...


WHY??? Why couldn't you, say, have all those classes outside at the
namespace level? And why do you keep all those members if they are
not always used? Shouldn't they all be in a class hierarchy and then
in a list/map/set of base class pointers? What is it you're trying to
model here?

> [..]


V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
 
PSN
Guest
Posts: n/a
 
      10-16-2006
HI,
thanks for your reply ..

it is a complex structure representing, let me just put it as a
communication protocol message (more specifically a MAC message) ..
more over i have no access to alter this code, other than use a pointer
to the object of the message ..

so simply put, neither can i add any code nor can i create a new
structure out of it .. just got to use this ..

still any ideas ..

Prakash
Victor Bazarov wrote:
> PSN wrote:
> > 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 ...

>
> WHY??? Why couldn't you, say, have all those classes outside at the
> namespace level? And why do you keep all those members if they are
> not always used? Shouldn't they all be in a class hierarchy and then
> in a list/map/set of base class pointers? What is it you're trying to
> model here?
>
> > [..]

>
> V
> --
> Please remove capital 'A's when replying by e-mail
> I do not respond to top-posted replies, please don't ask


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Embedded languages based on early Ada (from "Re: Preferred OS, processor family for running embedded Ada?") Colin Paul Gloster VHDL 48 04-10-2007 10:31 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
How to display images embedded in e-mail as embedded, not attachments Jim Firefox 4 12-11-2004 05:36 AM
Databind an embedded control in an embedded datagrid Thomas Dodds ASP .Net Datagrid Control 0 07-26-2004 08:20 PM



Advertisments