c++ - 视觉形式的意外文件结束

标签 c++ forms unexpectendoffile

尝试运行代码时出现错误。我正在使用可视化表单。对比 2013

#include "MyForm.h"

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

[STAThread]

int main(array<String^>^ args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

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

MyForm.cpp(17): fatal error C1004: 发现意外的文件结尾

我的表格.h:

#pragma once

namespace Project1 {

    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:
        /// <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->SuspendLayout();
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(284, 262);
            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 MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
    }
    };
}

MyForm.cpp(17): fatal error C1004: 发现意外的文件结尾

最佳答案

我只是遗漏了代码中的一些内容。

#include "MyForm.h"

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

[STAThread]
void main(array<String^>^ arg) {
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);

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

关于c++ - 视觉形式的意外文件结束,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27748441/

相关文章:

c++ - 当第二个线程从 map 中删除值时如何恢复线程?

javascript - 如何禁用 NodeJs Express 中的按钮?

javascript - 尝试使用 Type= 和 OnClick= 使两个功能与一个按钮相关联

java - 声明 sigmoid 函数时出现的问题

php在数据库中创建具有未知数量列的html表

C++:带有成员的抽象类中的纯虚拟析构函数

c++ - 从 Windows 事件中唤醒 QThread

javascript - 为什么在正确验证表单之前调用表单操作?

c++ - 检查整个数组是否为空