Hi,
Here's the problem:
I have a:
And such code does not work - I mean that definition of foo *build() outside the class g. How should I code it?Code:class g { class foo; ... foo* build(); ... }; foo g::*build() { ... }
Regards.
Hi,
Here's the problem:
I have a:
And such code does not work - I mean that definition of foo *build() outside the class g. How should I code it?Code:class g { class foo; ... foo* build(); ... }; foo g::*build() { ... }
Regards.
>> foo* build();
The complete return type is "foo*". So...
ggCode:foo* g::build() {}
Minor change:Code:foo g::*build()
[edit]Curses, foiled again.[/edit]Code:foo *g::build()
Quzah.
Hope is the first step on the road to disappointment.
But now I have that errors:
Maybe I'll show the whole code:y.cpp:19: error: expected constructor, destructor, or type conversion before '*' token
y.cpp:19: error: expected `,' or `;' before '*' token
What's wrong with it?Code:#include <cstdio> class g { class foo; foo* build(); }; class g::foo { int y; foo(int i =0) { y=i; } }; foo* g::build() { foo *f; f=new foo; return f; } int main() { return 0; }
>What's wrong with it?
Two things: you don't qualify foo with g outside of the class or function body, and your constructor for foo is private, so it's no accessible from g unless you make it a friend. Try this instead:
Code:#include <cstdio> class g { class foo; foo* build(); }; class g::foo { int y; public: foo(int i =0) { y=i; } }; g::foo* g::build() { foo *f; f=new foo; return f; } int main() { return 0; }
My best code is written with the delete key.
i.e. you didn't qualify foo with g:: in some spots, and you need to do so.Two things: you don't qualify foo with g outside of the class or function body
>i.e. you didn't qualify foo with g:: in some spots, and you need to do so.
Was I being cryptic again?
My best code is written with the delete key.
Thank you very much guys.