|
I am writting a Windows Form application. However I noticed that all the functions added by Visual Studio is defined in the class. If I can remember correctly this makes them inline, which is an in appropriate form to use when you want to write a large function.
For instance I added the function (with theAdd Member void CreatePage() to the Form1, but it defines it in the class:
void CreatePage(){ }
When I try to define it outside the class using the form I learned for standard C++ classes
void Form1::CreatePage(){ }
The compiler says that it is not a class or namespace.
Any idea how I can define it outside the class? |
| everlearnin Monday, August 10, 2009 10:19 AM |
Actually in C# there is nothing like header, Here you have to write the function definition with-in the class.
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.- Marked As Answer byLing WangMSFT, ModeratorMonday, August 17, 2009 1:54 AM
-
|
| _SuDhiR_ Monday, August 10, 2009 10:51 AM |
Your code won't compile because you forgot to #include "Form1.h". You are not writing C++ code anymore, this is a different language called C++/CLI. The standard C++ rulez no longer apply and that includes separating the declarations from their implementation. Don't fight the designer, keep your code inside the .h file. And pick up a book about the language, it is different enough to get you into a lot of trouble if you don't learn it. In fact, since you need to learn a new language anyway, it would be wise to make that C#. Writing WF apps in C++/CLI is deprecated.
Hans Passant.- Marked As Answer byLing WangMSFT, ModeratorMonday, August 17, 2009 1:54 AM
-
|
| nobugz Monday, August 10, 2009 11:50 AM |
Which language you using???
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.
|
| _SuDhiR_ Monday, August 10, 2009 10:27 AM |
To be honest the more I look at the forums for CLR .NET and Widows Forms the more I get the idea I am writting in C#. However, I don't know C# I only know C++ and I installed my Visual Studio to be VC++, so my logic tells me I am writing in C++ or Visual C++, which to me are one and the same.
The reason this is so strange to me is when I use Add Member Function Wizard for MFC it put the function declaration in the class and used the form I described above for standard C++ class functions for the declaration. But using the same Wizard in Windows Forms it puts the entire function inside the class. |
| everlearnin Monday, August 10, 2009 10:45 AM |
Actually in C# there is nothing like header, Here you have to write the function definition with-in the class.
Please mark the post as answer if it is helpfull to you because it boosts the members to answer more and more.- Marked As Answer byLing WangMSFT, ModeratorMonday, August 17, 2009 1:54 AM
-
|
| _SuDhiR_ Monday, August 10, 2009 10:51 AM |
Ok I suppose I just have to except that this is the way it is done when targeting the CLR. |
| everlearnin Monday, August 10, 2009 11:15 AM |
Your code won't compile because you forgot to #include "Form1.h". You are not writing C++ code anymore, this is a different language called C++/CLI. The standard C++ rulez no longer apply and that includes separating the declarations from their implementation. Don't fight the designer, keep your code inside the .h file. And pick up a book about the language, it is different enough to get you into a lot of trouble if you don't learn it. In fact, since you need to learn a new language anyway, it would be wise to make that C#. Writing WF apps in C++/CLI is deprecated.
Hans Passant.- Marked As Answer byLing WangMSFT, ModeratorMonday, August 17, 2009 1:54 AM
-
|
| nobugz Monday, August 10, 2009 11:50 AM |