473,326 Members | 2,095 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

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

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
2 2303
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert | last post by:
Python doesn't know the class of a method when container not direct class attribute: >>> class X: .... def f():pass .... g=f .... l= .... >>> X.g <unbound method X.f>
66
by: Mike Stenzler | last post by:
I am new to Template programming and I would like to create an array of user-defined class objects using MFC CArray. Normally I would use linked list processing - create an object class and then an...
4
by: mchoya | last post by:
I'm so frustrated. I'm beginning school next week and I have been working on a simple program for several days now without being able to complete it. (Though I have brushed up on a lot of C++...
2
by: Mika M | last post by:
Hi! My application uses self made Class. When I create an instance of it, class creates temporary file in constructor, and this file is in use as long as instance of class is in use. After...
14
by: Jamey Shuemaker | last post by:
Greetings all, I've been reading for the last couple hours posts on this site and various MS sites about reference libraries and class modules. System: Windows 2K running an A2K db with...
15
by: Laurent Lequenne | last post by:
Hello All, I'm currently developing a free windows Scrabble (in french :)) application that uses extensively the WebBrowser class of NET 2.0 for configuration, and data browsing. It works 100%...
32
by: Matias Jansson | last post by:
I come from a background of Java and C# where it is common practise to have one class per file in the file/project structure. As I have understood it, it is more common practice to have many...
41
by: Chris Lasher | last post by:
A friend of mine with a programming background in Java and Perl places each class in its own separate file in . I informed him that keeping all related classes together in a single file is more in...
6
by: Dan Smithers | last post by:
I want to write my own class derived from the ostream class. I have been getting errors with my templates: First, I get an error writing a nested template. If I leave the function definition...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.