Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nested C++ classes



Francisco Tolmasky wrote:
| I'm not sure if this is a C++ issue or a project builder issue since I
| seem to remember it happening in Codewarrior too, but why does this
| work:
|
| class someClass
| {
| class nested
| {
| //...
| int a(void) const { return 1; }
| };
|
| //...
| }
|
| but this tells me a() is not defined:
|
| in .h:
|
| class someClass
| {
| class nested
| {
| //...
| int a(void) const;
| };
|
| //...
| }
|
| in .cpp:
|
| int someClass::nested::a(void) const
| {
| return 1;
| }
|
| Any help is greatly appreciated, thanks in advance,

Try posting the simplest *complete* example you can of code that demonstrates the problem (that is, something we could cut and paste into a file and compile and see the problem), and quote the *exact* error message. (Make sure we know which line in the source code produces the error message.) Merely saying that "this tells me a() is not defined" doesn't tell us anything, because we have no context--we don't know what you did that made the message appear. There could be any of a variety of causes for the problem. Since we don't know exactly what you're doing, all we can do is speculate. (For instance, it makes a big difference whether it's the compiler or the linker saying that a() is undefined.)

FYI: it's generally regarded as bad C++ style to write "a(void)" instead of just "a()". This is one of the differences between C and C++: C interprets "a()" to mean "whether a() takes arguments or not is unspecified", while C++ interprets "a()" to mean "a() takes no arguments".

Glen Fisher
_______________________________________________
projectbuilder-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/projectbuilder-users
Do not post admin requests to the list. They will be ignored.

References: 
 >nested C++ classes (From: Francisco Tolmasky <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.