Lost Password?


  #1 (permalink)  
Old 06-24-2006, 01:01 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default Multiple classes in one namespace

I'm having problems with one of my projects. I created a windows .net form and want to include more than one namespace in the class. I create the second class after my form class but when I compile it doesn't recognize the data. I get a syntax error (Syntax Error: Identifier accessData) and a undeclared identifier error. If I move the second class to the top everything works but then the designer wont run. How can I use this class or define it before the first class? Here is an example:

namespace spaceName
{

public __gc class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();

}

........... Code here

// Trying to call the second class here:
accessData* data = new AccessData();


}; // end the class

// Create another class
public __gc clase accessData
{
.. Code here
};
} // End Namespace
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 06-26-2006, 03:08 PM
RobSoftware RobSoftware is offline
Programmer
 
Join Date: Nov 2005
Posts: 143
Rep Power: 12
RobSoftware is on a distinguished road
Default

The first class has to be class derived from the Form. That is why you see a designer error.

You can do a forward declaration in Form.h to get it to work or simply create a new class file for your project.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-29-2006, 04:35 PM
NeedHelp NeedHelp is offline
Programming God
 
Join Date: May 2006
Posts: 527
Rep Power: 13
NeedHelp is on a distinguished road
Default

Ahh, I see. If I move the first class the designer doesn't work. I've put the class in a seperate file and included it which also works just fine. How do I do a forward declaration?
__________________
I Need Help
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue writing to file: pointer to a class which contains pointers to other classes Sheemer C and C++ 0 08-21-2007 02:17 AM
Abstract Classes CyberByte C and C++ 1 02-21-2007 07:22 PM
Data and Classes Sionofdarkness Java Help 5 08-23-2006 10:18 PM
Classes, Methods, and Objects Sionofdarkness Java Help 6 08-21-2006 01:55 PM
understanding classes Chan C# Programming 3 07-17-2006 01:19 AM


All times are GMT -5. The time now is 05:38 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads