Jump to content

Multiple classes in one namespace

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
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

#2
RobSoftware

RobSoftware

    Programmer

  • Members
  • PipPipPipPip
  • 143 posts
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.

#3
Guest_NeedHelp_*

Guest_NeedHelp_*
  • Guests
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?