By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,502 Members | 1,204 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,502 IT Pros & Developers. It's quick & easy.

Use _gc class from another file - what have I missed?

P: n/a
Nik
Hi,

I'm trying (and failing) to learn MC++ and I get the
feeling that when I ask this question, the proverbial
record will scratch to a halt and everyone will stare at
me as though I'm totally weird, but here goes...

Using VS.NET 2003, I have created a MC++ .NET Class
Library project. I have create a class in the default
header file created by the project.

So far, so good. :o)

In C# (my normal mode of operation), I would normally
create another .cs file to hold a second class and,
assuming that the two classes shared a common namespace, I
would be able to use one class in the other. Therefore
this is what I tried to do in MC++, by creating a new
header and associated cpp file. I wrote the second class
in the header file and this is where I'm stuck because I
can't use the second class in the first because the
compiler tells me:

error C2061: syntax error : indetifier 'MyClassName'

'Ahhh', thought I. Perhaps it wants me to specify the
full namespace ('explicit is good' and all, or so I'm led
to believe). However, if I reference the class with the
full namespace (MyNamespace::MyClassName) the compiler
tells me:

error C2039: 'MyClassName' : is not a member
of 'MyNamespace'

However, the IntelliSense picks it up okay and if I hover
over the class name in the assignment statement, the
tooltip seems to display the correct class too.

Am I going mad? Is there a philosophy I'm missing which
dictates that all classes must be contained in the same
file? Or am I simply missing a #using clause somewhere?
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You'll have to:
#include "yoursecondheader"

before using any classes that are defined in it.

"Nik" <ni**********@N0SP4M.scottish-southern.co.uk> wrote in message
news:02****************************@phx.gbl...
Hi,

I'm trying (and failing) to learn MC++ and I get the
feeling that when I ask this question, the proverbial
record will scratch to a halt and everyone will stare at
me as though I'm totally weird, but here goes...

Using VS.NET 2003, I have created a MC++ .NET Class
Library project. I have create a class in the default
header file created by the project.

So far, so good. :o)

In C# (my normal mode of operation), I would normally
create another .cs file to hold a second class and,
assuming that the two classes shared a common namespace, I
would be able to use one class in the other. Therefore
this is what I tried to do in MC++, by creating a new
header and associated cpp file. I wrote the second class
in the header file and this is where I'm stuck because I
can't use the second class in the first because the
compiler tells me:

error C2061: syntax error : indetifier 'MyClassName'

'Ahhh', thought I. Perhaps it wants me to specify the
full namespace ('explicit is good' and all, or so I'm led
to believe). However, if I reference the class with the
full namespace (MyNamespace::MyClassName) the compiler
tells me:

error C2039: 'MyClassName' : is not a member
of 'MyNamespace'

However, the IntelliSense picks it up okay and if I hover
over the class name in the assignment statement, the
tooltip seems to display the correct class too.

Am I going mad? Is there a philosophy I'm missing which
dictates that all classes must be contained in the same
file? Or am I simply missing a #using clause somewhere?


Nov 16 '05 #2

P: n/a
Nik
Thanks Leon, you're a genius. :o) It does beg another
question though - what role does the namespace play in
MC++? In C#, it allows access to the other members at
design time, but MC++ still requires explicit declaration.
I'm missing a concept here I think.

Thanks,

Nik.
-----Original Message-----
You'll have to:
#include "yoursecondheader"

before using any classes that are defined in it.

"Nik" <ni**********@N0SP4M.scottish-southern.co.uk> wrote in messagenews:02****************************@phx.gbl...
Hi,

I'm trying (and failing) to learn MC++ and I get the
feeling that when I ask this question, the proverbial
record will scratch to a halt and everyone will stare at
me as though I'm totally weird, but here goes...

Using VS.NET 2003, I have created a MC++ .NET Class
Library project. I have create a class in the default
header file created by the project.

So far, so good. :o)

In C# (my normal mode of operation), I would normally
create another .cs file to hold a second class and,
assuming that the two classes shared a common namespace, I would be able to use one class in the other. Therefore
this is what I tried to do in MC++, by creating a new
header and associated cpp file. I wrote the second class in the header file and this is where I'm stuck because I
can't use the second class in the first because the
compiler tells me:

error C2061: syntax error : indetifier 'MyClassName'

'Ahhh', thought I. Perhaps it wants me to specify the
full namespace ('explicit is good' and all, or so I'm led to believe). However, if I reference the class with the
full namespace (MyNamespace::MyClassName) the compiler
tells me:

error C2039: 'MyClassName' : is not a member
of 'MyNamespace'

However, the IntelliSense picks it up okay and if I hover over the class name in the assignment statement, the
tooltip seems to display the correct class too.

Am I going mad? Is there a philosophy I'm missing which
dictates that all classes must be contained in the same
file? Or am I simply missing a #using clause somewhere?


.

Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.