C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

undefined type

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German)
View previous topic :: View next topic  
Author Message
Daniel Sch374le
Guest





PostPosted: Fri Jun 17, 2005 5:07 pm    Post subject: undefined type Reply with quote



Hallo newsgroup,

ich möchte folgenden Design benutzen, und um die Übersichtlichkeit nicht
zu verlieren, möchte ich class node unten separat implementieren.
Leider geht es nicht durch den Compiler, weil dieser wahrscheinlich
bei "new node[]" den ganzen Typ node kennen möchte.
Habe ich irgendeine andere Alternative, ausser doch class node
drinn in der classe net zu implementieren?

class net
{
private:
class node;
public:
net(size_t numClients) : nClients(numClients)
{
nodes = new node[nClients];
}
~net() { delete [] nodes; }
private:
node * nodes;
size_t nClients;
};

class net::node
{
/**/
};

Gruss, Daniel


--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de
Back to top
Michael Bieber
Guest





PostPosted: Fri Jun 17, 2005 5:31 pm    Post subject: Re: undefined type Reply with quote



Daniel Schüle wrote:

Quote:
Hallo newsgroup,

ich möchte folgenden Design benutzen, und um die Übersichtlichkeit nicht
zu verlieren, möchte ich class node unten separat implementieren.

Wenn du schon uebersichtlich sein willst, warum schiebst du c/dtor nicht
in ein Implementierungsfile ? Dort hast du dann auch deinen voll
qualifizierten Typ.

Micha

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Rolf Magnus
Guest





PostPosted: Fri Jun 17, 2005 5:36 pm    Post subject: Re: undefined type Reply with quote



Daniel Schüle wrote:

Quote:
Hallo newsgroup,

ich möchte folgenden Design benutzen, und um die Übersichtlichkeit
nicht zu verlieren, möchte ich class node unten separat implementieren.
Leider geht es nicht durch den Compiler, weil dieser wahrscheinlich
bei "new node[]" den ganzen Typ node kennen möchte.

Das möchte er. Wie sollte er sonst z.B. wissen, wieviel Speicher der
operator new reservieren muß und ob ein Konstruktor ausgeführt werden muß?

Quote:
Habe ich irgendeine andere Alternative, ausser doch class node
drinn in der classe net zu implementieren?

Ja, die übliche. Trennung der Deklaration der Funktionen von der Definition.

Quote:
class net
{
private:
class node;
public:
net(size_t numClients) : nClients(numClients)
{
nodes = new node[nClients];
}
~net() { delete [] nodes; }
private:
node * nodes;
size_t nClients;
};

class net
{
private:
class node;
public:
net(size_t numClients);
~net();
private:
node * nodes;
size_t nClients;
};

Quote:
class net::node
{
/**/
};

net::net(size_t numClients)
: nodes(new node[numClients]),
nClients(numClients)
{
}

net::~net()
{
delete [] nodes;
}

PS: hier fehlen natürlich noch Kopierkonstruktor und Zuweisungsoperator.

--
de.comp.lang.iso-c++ - Moderation: mailto:voyager+mod (AT) bud (DOT) prima.de
FAQ: http://www.voyager.prima.de/cpp/ mailto:voyager+send-faq (AT) bud (DOT) prima.de

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ (German) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.