From: O.o on
This has been driving me completely bonkers for the past two days now,
and I'm at my wit's end. Let's say I have a class Foo, which is
defined in Foo.h and implemented in Foo.cpp. In another class, I want
to instantiate a Foo object. Pretty simple.

#include "Foo.h"

int OtherClass::SomeFunction(void)
{
Foo foo; //C2065: 'Foo': undeclared identifier
return 0;
}

I'm six-trillion % certain that Foo.h and Foo.cpp are compiled. In
fact, if when use the scope or member operator on 'Foo' or 'foo',
Intellinonsense CORRECTLY LISTS ITS ACCESSIBLE MEMBERS!!!! What am I
missing here??

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Alf P. Steinbach on
* O.o:
> This has been driving me completely bonkers for the past two days now,
> and I'm at my wit's end. Let's say I have a class Foo, which is
> defined in Foo.h and implemented in Foo.cpp. In another class, I want
> to instantiate a Foo object. Pretty simple.
>
> #include "Foo.h"
>
> int OtherClass::SomeFunction(void)
> {
> Foo foo; //C2065: 'Foo': undeclared identifier
> return 0;
> }
>
> I'm six-trillion % certain that Foo.h and Foo.cpp are compiled. In
> fact, if when use the scope or member operator on 'Foo' or 'foo',
> Intellinonsense CORRECTLY LISTS ITS ACCESSIBLE MEMBERS!!!! What am I
> missing here??

See that FAQ item on how to post a question about Code That Does Not Work Correctly.

Then repost.


Cheers & hth.,

- Alf

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Robert Hairgrove on


O.o wrote:

> #include "Foo.h"

>

> int OtherClass::SomeFunction(void)

> {

> Foo foo; //C2065: 'Foo': undeclared identifier

> return 0;

> }

>

> I'm six-trillion % certain that Foo.h and Foo.cpp are compiled. In

> fact, if when use the scope or member operator on 'Foo' or 'foo',

> Intellinonsense CORRECTLY LISTS ITS ACCESSIBLE MEMBERS!!!! What am I

> missing here??





Without seeing any of the code in Foo.h, it is very hard to say.



--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: Martin B. on
O.o wrote:
> This has been driving me completely bonkers for the past two days now,
> and I'm at my wit's end. Let's say I have a class Foo, which is
> defined in Foo.h and implemented in Foo.cpp. In another class, I want
> to instantiate a Foo object. Pretty simple.
>
> #include "Foo.h"
>
> int OtherClass::SomeFunction(void)
> {
> Foo foo; //C2065: 'Foo': undeclared identifier
> return 0;
> }
>
> I'm six-trillion % certain that Foo.h and Foo.cpp are compiled. In

Note that Foo.cpp needn't be compiled for this code here to compile.
(but for it to link)
You should have posted what Foo.h contains, maybe there's something there.

> fact, if when use the scope or member operator on 'Foo' or 'foo',
> Intellinonsense CORRECTLY LISTS ITS ACCESSIBLE MEMBERS!!!! What am I
> missing here??
>

Note that Intellisense in Visual Studio is completely independent of the
compiler. So often it will correctly contextualize types that are not
visible in your current file because I think it's database is fairly
independent of any header include directives.

br,
Martin

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

From: restor on
On 12 Dec, 11:10, "O.o" <stephen.k.robe...(a)gmail.com> wrote:
> This has been driving me completely bonkers for the past two days now,
> and I'm at my wit's end. Let's say I have a class Foo, which is
> defined in Foo.h and implemented in Foo.cpp. In another class, I want
> to instantiate a Foo object. Pretty simple.
>
> #include "Foo.h"
>
> int OtherClass::SomeFunction(void)
> {
> Foo foo; //C2065: 'Foo': undeclared identifier
> return 0;
>
> }
>
> I'm six-trillion % certain that Foo.h and Foo.cpp are compiled. In
> fact, if when use the scope or member operator on 'Foo' or 'foo',
> Intellinonsense CORRECTLY LISTS ITS ACCESSIBLE MEMBERS!!!! What am I
> missing here??

Hi,
Please note, that the example you enclosed is not sufficient to tell
what is wrong with your program. You say you include the contents of
the file Foo.h, but ho can we know if there is any class whatsoever
defined in that class?
Also note that Microsoft's intellisense uses different mechanisms for
looking for available functions/classes than the compiler.
Intellisense has to be fast; the compiler has to obay C++ rules. The
two goals are different.
I can only guess what the problem is.Let me give you a list:

1. You or someone else in the project used too clever macros that
redefine the meaning of word "class" or "Foo".

2. Class Foo is defined in a namespace (e.g. FooNS); and you forgot to
type FooNS::Foo.

3. You have two files Foo.h and the compiler parses not the one you
think it should.

Regards,
&rzej


--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]