这是出现错误的代码部分。
#include "MyForm.h"
; using namespace System;
using namespace System::Windows::Forms;
[STAThread]
void main(array<String^>^ args)
{
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
V_Hello_World::MyForm form;
Application::Run(%form);
}
错误是:错误1错误C1075:在左括号之前找到的文件结尾&#39; {&#39;。我不确定为什么会出现这种错误,但非常感谢一些帮助。
MyForm.h
#pragma once
namespace V_Hello_World {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for MyForm
/// </summary>
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
protected:
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Font = (gcnew System::Drawing::Font(L"Minion Pro", 14.25F, System::Drawing::FontStyle::Bold, System::Drawing::GraphicsUnit::Point,
static_cast<System::Byte>(0)));
this->button1->Location = System::Drawing::Point(12, 12);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(260, 237);
this->button1->TabIndex = 0;
this->button1->Text = L"Say Hello";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(284, 261);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
{
MessageBox::Show("Hello World!");
}
};
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
}
答案 0 :(得分:1)
您开始在
运行问题#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
{
MessageBox::Show("Hello World!");
}
};
private: System::Void MyForm_Load(System::Object^ sender, System::EventArgs^ e) {
}
}
你的第一个问题是你有button1_Click
的两个开放花括号,但只有一个闭括号。你应该只能删除其中一个开放的花括号。你的第二个问题是MyForm_Load
不在课堂上。您需要将其移动到类声明中。