Can't instantiate a class inside another class

Hi. The code below generates the errors:

Error 1 error C2065: 'AboutDialog' : undeclared identifier 

Error 2 error C2065: 'About' : undeclared identifier 

Error 3 error C2061: syntax error : identifier 'AboutDialog' 

Error 4 error C2227: left of '->Show' must point to class/struct/union/generic type 


   AboutDialog^ About = gcnew AboutDialog();

   About->Show();


This is a Windows Forms app. With two forms; a Main form and an About Dialog Box.

I am trying to call the About Box class from inside the Main form class.

(I have written the same program in VB,  VC#, and VJ# with no problem)

 Thanks



Answer this question

Can't instantiate a class inside another class

  • Amir Ashkan Maalhagh

    c# ShowDialog()

    Kuphryn


  • PlayJunior

    I solved my issue. It appears I had a Naming issue (Files, Namespaces, Classes, etec.)

    Thanks again for your help.


  • gman1

    The difference is that in C++ this .cpp file needs to #include the header file that defines the AboutDialog class. None of those other languages require that.



  • Houseofbugs

    Thank you very much cgraus. -My program ran, but now I have another problem.

    Instead of opening up my AboutDialog form it opened up a blank form.

    Also, when I tried to debug the program, stored in the 'About' object was: 0x012e1e24 {tableLayoutPanel=<undefined value>...}

    I don't understand why it's doing that.

     


    Can't instantiate a class inside another class

    Hi. The code below generates the errors:

    Error 1 error C2065: 'AboutDialog' : undeclared identifier 

    Error 2 error C2065: 'About' : undeclared identifier 

    Error 3 error C2061: syntax error : identifier 'AboutDialog' 

    Error 4 error C2227: left of '->Show' must point to class/struct/union/generic type 


       AboutDialog^ About = gcnew AboutDialog();

       About->Show();


    This is a Windows Forms app. With two forms; a Main form and an About Dialog Box.

    I am trying to call the About Box class from inside the Main form class.

    (I have written the same program in VB,  VC#, and VJ# with no problem)

     Thanks


  • Can't instantiate a class inside another class