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

N

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. :blush:)

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?
 
L

Leon Finker

You'll have to:
#include "yoursecondheader"

before using any classes that are defined in it.
 
N

Nik

Thanks Leon, you're a genius. :blush:) 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top