473,657 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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::M yClassName) 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 2330
You'll have to:
#include "yoursecondhead er"

before using any classes that are defined in it.

"Nik" <ni**********@N 0SP4M.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::M yClassName) 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 "yoursecondhead er"

before using any classes that are defined in it.

"Nik" <ni**********@N 0SP4M.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::M yClassName) 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
3045
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
6605
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 object-list class, but in this instance array processing would be more efficient. However I need to use arrays that can dynamically shrink and grow ala Visual Basic arrays. I'm confused as to how to declare/implement the CArray using my Class....
4
1672
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++ while trying.) I realize this code is long but, I'm not sure of any other way to display the issue. The header file and ?implementation file work. (This assignment was building on another in which I created the header and implementation with a...
2
5490
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 instance of class will be removed, temporary needed file should be deleted too. So how can I do it? It there destructor for VB.NET class where this file can be deleted or something like that? I'm quite newbie with VB.NET OOP programming, but I have...
14
5416
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 various standard modules and a handful of custom class modules. Stripped out the standard and class modules and put them in a stand-alone mdb which was then converted to an mde and referenced from another mdb (later, it will be an mde, but i'm only in...
15
5677
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% on my machine, with the WebBrowser Class, and the Microsoft.MsHtml component. I can access all elements on the pages through the events, I can change some parts. Everything is rendered with XSLTs and changing directly the document through the ...
32
5803
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 classes in a Python module/file. What is the motivation behind it, would it be a bad idea to have a guideline in your project that promotes a one class per file structure (assuming most of the programmers a background similar to mine)?
41
13815
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 the Python idiom than one file per class. He asked why, and frankly, his valid question has me flummoxed. I tried to rationalize this Python idiom by claiming a file--a single module--makes for a great container of code which is logically tied...
6
2607
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 inside template class definition (commented out at //1) then it compiles and runs fine, but if I declare and define the function separately (at //2). Is the following syntax supported by g++?
0
8303
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8821
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8502
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8602
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7316
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.