0
votes

Today we've been starting to use C++ and we've encountered a problem with creating our form.

I've been looking at a video which contains a tutorial how to make a Form in C++. I'm used to use C# instead of C++, so I'm really a beginner of the beginning. I've set my SubSystem to Windows and my EntryPoint to main.

I've used this code:

 #include "MyForm.h"

using namespace System;
using namespace System::Windows::Forms;


[STAThread]
void main(array<String^>^ args) 
{

    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

    Project1::MyForm form;
    Application::Run(%form);
}

In the MyForm.cpp

The errors:

Error 5 error C2065: 'form' : undeclared identifier
Error 6 error C2065: 'form' : undeclared identifier
Error 3 error C2065: 'MyForm' : undeclared identifier
Error 4 error C2146: syntax error : missing ';' before identifier 'form'
Error 2 error C2653: 'Project1' : is not a class or namespace name
8 IntelliSense: expected a ';'
9 IntelliSense: identifier "form" is undefined
7 IntelliSense: name followed by '::' must be a class or namespace name
Warning 1 warning C4829: Possibly incorrect parameters to function main. Consider 'int main(Platform::Array^ argv)'

I apologise for not posting an image due to my lack of reputation...

I haven't configured anything further than this. Am I missing something?

Thanks in advance!

Kind regards,

Sjors

2
It doesn't find the declaration of Project1::MyForm, add the reference of the related assembly and use the namespace - Matt
Note that you are not actually using C++, but C++/CLI. These are two different languages. - Medinoc
@Matt Thank you very much, you've got me thinking about what could be wrong. And I/you fixed it! Have a great day! - Sj03rs
array<String^>^ is mainly a C++/CLI type, but the type recommended by IntelliSense, Platform::Array, is a C++/CX type. Are you sure you're using the right compiler? - Medinoc

2 Answers

1
votes

Changed Project1 to Test100920141327, which is my project name, just a really dumb thing actually. I didn't know the Project1 was a name of your project. Thanks everyone for supporting!

 #include "MyForm.h"

using namespace System;
using namespace System::Windows::Forms;


[STAThread]
void main(array<String^>^ args) 
{

    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

    Test100920141327::MyForm form;
    Application::Run(%form);
}

Kind regards,

Sjors

0
votes

I had the same problem. I solved it in this way:

In the properties window of my project I set the Configuration drop-down list to Active(Debug). Originally it was Debug in my case.