Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

- - - - -

Multiple classes in one namespace

Managed C++ namespace

  • Please log in to reply
2 replies to this topic

#1 Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guest

Posted 24 June 2006 - 09:01 AM

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
  • 0

#2 RobSoftware

RobSoftware

    CC Addict

  • Just Joined
  • PipPipPipPipPip
  • 141 posts

Posted 26 June 2006 - 11:08 AM

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.
  • 0

#3 Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guest

Posted 29 June 2006 - 12:35 PM

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?
  • 0





Also tagged with one or more of these keywords: Managed C++, namespace

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download