我是Visual C ++的新手,已经在我的项目中添加了一个表单,它给了我一个带有完全自动生成代码的文件kamisado_board.h,我已将其包含在本文的底部以供参考。我认为这很好,因为它是由程序生成的。
我已经编写了一个单独的文件kamisado_main.cpp,并在编译时遇到以下错误:
"错误1错误C2065:' KamisadoBoard' :未声明的标识符" "错误2错误C2146:语法错误:丢失&#39 ;;'在标识符'形式'"之前 "错误3错误C2065:'表格' :未声明的标识符" "错误4错误C2061:语法错误:标识符' KamisadoBoard'" "错误5错误C2065:'表格' :未声明的标识符" "错误6错误C2227:左边的' - >显示'必须指向class / struct / union / generic类型"
我已在此处包含此文件的代码:
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include <iostream>
#include "kamisado_board.h"
int
main(int argc, char *argv[])
{
bool running = true;
int input = 0;
KamisadoBoard form = gcnew KamisadoBoard;
return(0);
}
我认为从我的C经验中可能缺少#include(我的工作代码是C,但我是C ++的新手),但它仍然在抱怨,包括kamisado_board.h。我在某个地方错过了一条线吗?我已经将自动生成的表单文件kamisado_board.h包含在下面作为参考,虽然我假设这是正确的!提前谢谢。
//kamisado_board.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 KamisadoBoard
/// </summary>
public ref class KamisadoBoard : public System::Windows::Forms::Form
{
public:
KamisadoBoard(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~KamisadoBoard()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
private: System::Windows::Forms::Button^ button2;
private: System::Windows::Forms::Button^ button3;
private: System::Windows::Forms::Button^ button4;
private: System::Windows::Forms::Button^ button5;
private: System::Windows::Forms::Button^ button6;
private: System::Windows::Forms::Button^ button7;
private: System::Windows::Forms::Button^ button8;
private: System::Windows::Forms::Button^ button9;
private: System::Windows::Forms::Button^ button10;
private: System::Windows::Forms::Button^ button11;
private: System::Windows::Forms::Button^ button12;
private: System::Windows::Forms::Button^ button13;
private: System::Windows::Forms::Button^ button14;
private: System::Windows::Forms::Button^ button15;
private: System::Windows::Forms::Button^ button16;
private: System::Windows::Forms::Button^ button17;
private: System::Windows::Forms::Button^ button18;
private: System::Windows::Forms::Button^ button19;
private: System::Windows::Forms::Button^ button20;
private: System::Windows::Forms::Button^ button21;
private: System::Windows::Forms::Button^ button22;
private: System::Windows::Forms::Button^ button23;
private: System::Windows::Forms::Button^ button24;
private: System::Windows::Forms::Button^ button25;
private: System::Windows::Forms::Button^ button26;
private: System::Windows::Forms::Button^ button27;
private: System::Windows::Forms::Button^ button28;
private: System::Windows::Forms::Button^ button29;
private: System::Windows::Forms::Button^ button30;
private: System::Windows::Forms::Button^ button31;
private: System::Windows::Forms::Button^ button32;
private: System::Windows::Forms::Button^ button33;
private: System::Windows::Forms::Button^ button34;
private: System::Windows::Forms::Button^ button35;
private: System::Windows::Forms::Button^ button36;
private: System::Windows::Forms::Button^ button37;
private: System::Windows::Forms::Button^ button38;
private: System::Windows::Forms::Button^ button39;
private: System::Windows::Forms::Button^ button40;
private: System::Windows::Forms::Button^ button41;
private: System::Windows::Forms::Button^ button42;
private: System::Windows::Forms::Button^ button43;
private: System::Windows::Forms::Button^ button44;
private: System::Windows::Forms::Button^ button45;
private: System::Windows::Forms::Button^ button46;
private: System::Windows::Forms::Button^ button47;
private: System::Windows::Forms::Button^ button48;
private: System::Windows::Forms::Button^ button49;
private: System::Windows::Forms::Button^ button50;
private: System::Windows::Forms::Button^ button51;
private: System::Windows::Forms::Button^ button52;
private: System::Windows::Forms::Button^ button53;
private: System::Windows::Forms::Button^ button54;
private: System::Windows::Forms::Button^ button55;
private: System::Windows::Forms::Button^ button56;
private: System::Windows::Forms::Button^ button57;
private: System::Windows::Forms::Button^ button58;
private: System::Windows::Forms::Button^ button59;
private: System::Windows::Forms::Button^ button60;
private: System::Windows::Forms::Button^ button61;
private: System::Windows::Forms::Button^ button62;
private: System::Windows::Forms::Button^ button63;
private: System::Windows::Forms::Button^ button64;
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->button2 = (gcnew System::Windows::Forms::Button());
this->button3 = (gcnew System::Windows::Forms::Button());
this->button4 = (gcnew System::Windows::Forms::Button());
this->button5 = (gcnew System::Windows::Forms::Button());
this->button6 = (gcnew System::Windows::Forms::Button());
this->button7 = (gcnew System::Windows::Forms::Button());
this->button8 = (gcnew System::Windows::Forms::Button());
this->button9 = (gcnew System::Windows::Forms::Button());
this->button10 = (gcnew System::Windows::Forms::Button());
this->button11 = (gcnew System::Windows::Forms::Button());
this->button12 = (gcnew System::Windows::Forms::Button());
this->button13 = (gcnew System::Windows::Forms::Button());
this->button14 = (gcnew System::Windows::Forms::Button());
this->button15 = (gcnew System::Windows::Forms::Button());
this->button16 = (gcnew System::Windows::Forms::Button());
this->button17 = (gcnew System::Windows::Forms::Button());
this->button18 = (gcnew System::Windows::Forms::Button());
this->button19 = (gcnew System::Windows::Forms::Button());
this->button20 = (gcnew System::Windows::Forms::Button());
this->button21 = (gcnew System::Windows::Forms::Button());
this->button22 = (gcnew System::Windows::Forms::Button());
this->button23 = (gcnew System::Windows::Forms::Button());
this->button24 = (gcnew System::Windows::Forms::Button());
this->button25 = (gcnew System::Windows::Forms::Button());
this->button26 = (gcnew System::Windows::Forms::Button());
this->button27 = (gcnew System::Windows::Forms::Button());
this->button28 = (gcnew System::Windows::Forms::Button());
this->button29 = (gcnew System::Windows::Forms::Button());
this->button30 = (gcnew System::Windows::Forms::Button());
this->button31 = (gcnew System::Windows::Forms::Button());
this->button32 = (gcnew System::Windows::Forms::Button());
this->button33 = (gcnew System::Windows::Forms::Button());
this->button34 = (gcnew System::Windows::Forms::Button());
this->button35 = (gcnew System::Windows::Forms::Button());
this->button36 = (gcnew System::Windows::Forms::Button());
this->button37 = (gcnew System::Windows::Forms::Button());
this->button38 = (gcnew System::Windows::Forms::Button());
this->button39 = (gcnew System::Windows::Forms::Button());
this->button40 = (gcnew System::Windows::Forms::Button());
this->button41 = (gcnew System::Windows::Forms::Button());
this->button42 = (gcnew System::Windows::Forms::Button());
this->button43 = (gcnew System::Windows::Forms::Button());
this->button44 = (gcnew System::Windows::Forms::Button());
this->button45 = (gcnew System::Windows::Forms::Button());
this->button46 = (gcnew System::Windows::Forms::Button());
this->button47 = (gcnew System::Windows::Forms::Button());
this->button48 = (gcnew System::Windows::Forms::Button());
this->button49 = (gcnew System::Windows::Forms::Button());
this->button50 = (gcnew System::Windows::Forms::Button());
this->button51 = (gcnew System::Windows::Forms::Button());
this->button52 = (gcnew System::Windows::Forms::Button());
this->button53 = (gcnew System::Windows::Forms::Button());
this->button54 = (gcnew System::Windows::Forms::Button());
this->button55 = (gcnew System::Windows::Forms::Button());
this->button56 = (gcnew System::Windows::Forms::Button());
this->button57 = (gcnew System::Windows::Forms::Button());
this->button58 = (gcnew System::Windows::Forms::Button());
this->button59 = (gcnew System::Windows::Forms::Button());
this->button60 = (gcnew System::Windows::Forms::Button());
this->button61 = (gcnew System::Windows::Forms::Button());
this->button62 = (gcnew System::Windows::Forms::Button());
this->button63 = (gcnew System::Windows::Forms::Button());
this->button64 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->BackColor = System::Drawing::Color::Orange;
this->button1->Location = System::Drawing::Point(43, 24);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(23, 23);
this->button1->TabIndex = 0;
this->button1->UseVisualStyleBackColor = false;
//
// button2
//
this->button2->BackColor = System::Drawing::Color::Blue;
this->button2->Location = System::Drawing::Point(72, 24);
this->button2->Name = L"button2";
this->button2->Size = System::Drawing::Size(23, 23);
this->button2->TabIndex = 1;
this->button2->UseVisualStyleBackColor = false;
//
// button3
//
this->button3->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button3->Location = System::Drawing::Point(129, 24);
this->button3->Name = L"button3";
this->button3->Size = System::Drawing::Size(23, 23);
this->button3->TabIndex = 3;
this->button3->UseVisualStyleBackColor = false;
//
// button4
//
this->button4->BackColor = System::Drawing::Color::Purple;
this->button4->Location = System::Drawing::Point(100, 24);
this->button4->Name = L"button4";
this->button4->Size = System::Drawing::Size(23, 23);
this->button4->TabIndex = 2;
this->button4->UseVisualStyleBackColor = false;
//
// button5
//
this->button5->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button5->Location = System::Drawing::Point(244, 24);
this->button5->Name = L"button5";
this->button5->Size = System::Drawing::Size(23, 23);
this->button5->TabIndex = 7;
this->button5->UseVisualStyleBackColor = false;
//
// button6
//
this->button6->BackColor = System::Drawing::Color::Green;
this->button6->Location = System::Drawing::Point(215, 24);
this->button6->Name = L"button6";
this->button6->Size = System::Drawing::Size(23, 23);
this->button6->TabIndex = 6;
this->button6->UseVisualStyleBackColor = false;
//
// button7
//
this->button7->BackColor = System::Drawing::Color::Red;
this->button7->Location = System::Drawing::Point(187, 24);
this->button7->Name = L"button7";
this->button7->Size = System::Drawing::Size(23, 23);
this->button7->TabIndex = 5;
this->button7->UseVisualStyleBackColor = false;
//
// button8
//
this->button8->BackColor = System::Drawing::Color::Yellow;
this->button8->Location = System::Drawing::Point(158, 24);
this->button8->Name = L"button8";
this->button8->Size = System::Drawing::Size(23, 23);
this->button8->TabIndex = 4;
this->button8->UseVisualStyleBackColor = false;
//
// button9
//
this->button9->BackColor = System::Drawing::Color::Purple;
this->button9->Location = System::Drawing::Point(244, 53);
this->button9->Name = L"button9";
this->button9->Size = System::Drawing::Size(23, 23);
this->button9->TabIndex = 15;
this->button9->UseVisualStyleBackColor = false;
//
// button10
//
this->button10->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button10->Location = System::Drawing::Point(215, 53);
this->button10->Name = L"button10";
this->button10->Size = System::Drawing::Size(23, 23);
this->button10->TabIndex = 14;
this->button10->UseVisualStyleBackColor = false;
this->button10->Click += gcnew System::EventHandler(this, &KamisadoBoard::button10_Click);
//
// button11
//
this->button11->BackColor = System::Drawing::Color::Yellow;
this->button11->Location = System::Drawing::Point(187, 53);
this->button11->Name = L"button11";
this->button11->Size = System::Drawing::Size(23, 23);
this->button11->TabIndex = 13;
this->button11->UseVisualStyleBackColor = false;
//
// button12
//
this->button12->BackColor = System::Drawing::Color::Blue;
this->button12->Location = System::Drawing::Point(158, 53);
this->button12->Name = L"button12";
this->button12->Size = System::Drawing::Size(23, 23);
this->button12->TabIndex = 12;
this->button12->UseVisualStyleBackColor = false;
this->button12->Click += gcnew System::EventHandler(this, &KamisadoBoard::button12_Click);
//
// button13
//
this->button13->BackColor = System::Drawing::Color::Green;
this->button13->Location = System::Drawing::Point(129, 53);
this->button13->Name = L"button13";
this->button13->Size = System::Drawing::Size(23, 23);
this->button13->TabIndex = 11;
this->button13->UseVisualStyleBackColor = false;
this->button13->Click += gcnew System::EventHandler(this, &KamisadoBoard::button13_Click);
//
// button14
//
this->button14->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button14->Location = System::Drawing::Point(100, 53);
this->button14->Name = L"button14";
this->button14->Size = System::Drawing::Size(23, 23);
this->button14->TabIndex = 10;
this->button14->UseVisualStyleBackColor = false;
//
// button15
//
this->button15->BackColor = System::Drawing::Color::Orange;
this->button15->Location = System::Drawing::Point(72, 53);
this->button15->Name = L"button15";
this->button15->Size = System::Drawing::Size(23, 23);
this->button15->TabIndex = 9;
this->button15->UseVisualStyleBackColor = false;
//
// button16
//
this->button16->BackColor = System::Drawing::Color::Red;
this->button16->Location = System::Drawing::Point(43, 53);
this->button16->Name = L"button16";
this->button16->Size = System::Drawing::Size(23, 23);
this->button16->TabIndex = 8;
this->button16->UseVisualStyleBackColor = false;
//
// button17
//
this->button17->BackColor = System::Drawing::Color::Yellow;
this->button17->Location = System::Drawing::Point(244, 111);
this->button17->Name = L"button17";
this->button17->Size = System::Drawing::Size(23, 23);
this->button17->TabIndex = 31;
this->button17->UseVisualStyleBackColor = false;
//
// button18
//
this->button18->BackColor = System::Drawing::Color::Red;
this->button18->Location = System::Drawing::Point(215, 111);
this->button18->Name = L"button18";
this->button18->Size = System::Drawing::Size(23, 23);
this->button18->TabIndex = 30;
this->button18->UseVisualStyleBackColor = false;
//
// button19
//
this->button19->BackColor = System::Drawing::Color::Green;
this->button19->Location = System::Drawing::Point(187, 111);
this->button19->Name = L"button19";
this->button19->Size = System::Drawing::Size(23, 23);
this->button19->TabIndex = 29;
this->button19->UseVisualStyleBackColor = false;
//
// button20
//
this->button20->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button20->Location = System::Drawing::Point(158, 111);
this->button20->Name = L"button20";
this->button20->Size = System::Drawing::Size(23, 23);
this->button20->TabIndex = 28;
this->button20->UseVisualStyleBackColor = false;
//
// button21
//
this->button21->BackColor = System::Drawing::Color::Orange;
this->button21->Location = System::Drawing::Point(129, 111);
this->button21->Name = L"button21";
this->button21->Size = System::Drawing::Size(23, 23);
this->button21->TabIndex = 27;
this->button21->UseVisualStyleBackColor = false;
//
// button22
//
this->button22->BackColor = System::Drawing::Color::Blue;
this->button22->Location = System::Drawing::Point(100, 111);
this->button22->Name = L"button22";
this->button22->Size = System::Drawing::Size(23, 23);
this->button22->TabIndex = 26;
this->button22->UseVisualStyleBackColor = false;
//
// button23
//
this->button23->BackColor = System::Drawing::Color::Purple;
this->button23->Location = System::Drawing::Point(72, 111);
this->button23->Name = L"button23";
this->button23->Size = System::Drawing::Size(23, 23);
this->button23->TabIndex = 25;
this->button23->UseVisualStyleBackColor = false;
//
// button24
//
this->button24->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button24->Location = System::Drawing::Point(43, 111);
this->button24->Name = L"button24";
this->button24->Size = System::Drawing::Size(23, 23);
this->button24->TabIndex = 24;
this->button24->UseVisualStyleBackColor = false;
//
// button25
//
this->button25->BackColor = System::Drawing::Color::Blue;
this->button25->Location = System::Drawing::Point(244, 82);
this->button25->Name = L"button25";
this->button25->Size = System::Drawing::Size(23, 23);
this->button25->TabIndex = 23;
this->button25->UseVisualStyleBackColor = false;
//
// button26
//
this->button26->BackColor = System::Drawing::Color::Yellow;
this->button26->Location = System::Drawing::Point(215, 82);
this->button26->Name = L"button26";
this->button26->Size = System::Drawing::Size(23, 23);
this->button26->TabIndex = 22;
this->button26->UseVisualStyleBackColor = false;
//
// button27
//
this->button27->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(128)), static_cast<System::Int32>(static_cast<System::Byte>(64)),
static_cast<System::Int32>(static_cast<System::Byte>(0)));
this->button27->Location = System::Drawing::Point(187, 82);
this->button27->Name = L"button27";
this->button27->Size = System::Drawing::Size(23, 23);
this->button27->TabIndex = 21;
this->button27->UseVisualStyleBackColor = false;
//
// button28
//
this->button28->BackColor = System::Drawing::Color::Purple;
this->button28->Location = System::Drawing::Point(158, 82);
this->button28->Name = L"button28";
this->button28->Size = System::Drawing::Size(23, 23);
this->button28->TabIndex = 20;
this->button28->UseVisualStyleBackColor = false;
//
// button29
//
this->button29->BackColor = System::Drawing::Color::Red;
this->button29->Location = System::Drawing::Point(129, 82);
this->button29->Name = L"button29";
this->button29->Size = System::Drawing::Size(23, 23);
this->button29->TabIndex = 19;
this->button29->UseVisualStyleBackColor = false;
//
// button30
//
this->button30->BackColor = System::Drawing::Color::Orange;
this->button30->Location = System::Drawing::Point(100, 82);
this->button30->Name = L"button30";
this->button30->Size = System::Drawing::Size(23, 23);
this->button30->TabIndex = 18;
this->button30->UseVisualStyleBackColor = false;
//
// button31
//
this->button31->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button31->Location = System::Drawing::Point(72, 82);
this->button31->Name = L"button31";
this->button31->Size = System::Drawing::Size(23, 23);
this->button31->TabIndex = 17;
this->button31->UseVisualStyleBackColor = false;
//
// button32
//
this->button32->BackColor = System::Drawing::Color::Green;
this->button32->Location = System::Drawing::Point(43, 82);
this->button32->Name = L"button32";
this->button32->Size = System::Drawing::Size(23, 23);
this->button32->TabIndex = 16;
this->button32->UseVisualStyleBackColor = false;
//
// button33
//
this->button33->BackColor = System::Drawing::Color::Orange;
this->button33->Location = System::Drawing::Point(244, 225);
this->button33->Name = L"button33";
this->button33->Size = System::Drawing::Size(23, 23);
this->button33->TabIndex = 63;
this->button33->UseVisualStyleBackColor = false;
//
// button34
//
this->button34->BackColor = System::Drawing::Color::Blue;
this->button34->Location = System::Drawing::Point(215, 225);
this->button34->Name = L"button34";
this->button34->Size = System::Drawing::Size(23, 23);
this->button34->TabIndex = 62;
this->button34->UseVisualStyleBackColor = false;
//
// button35
//
this->button35->BackColor = System::Drawing::Color::Purple;
this->button35->Location = System::Drawing::Point(187, 225);
this->button35->Name = L"button35";
this->button35->Size = System::Drawing::Size(23, 23);
this->button35->TabIndex = 61;
this->button35->UseVisualStyleBackColor = false;
//
// button36
//
this->button36->BackColor = System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)), static_cast<System::Int32>(static_cast<System::Byte>(128)),
static_cast<System::Int32>(static_cast<System::Byte>(255)));
this->button36->Location = System::Drawing::Point(158, 225);
this->button36->Name = L"button36";
this->button36->Size = System::Drawing::Size(23, 23);
this->button36->TabIndex = 60;
this->button36->UseVisualStyleBackColor = false;
//
// button37
//
this->button37->BackColor = System::Drawing::Color::Yellow;
this->button37->Location = System::Drawing::Point(129, 225);
this->button37->Name = L"button37";
this->button37->Size = System::Drawing::Size(23, 23);
this->button37->TabIndex = 59;
this->button37->UseVisualStyleBackColor = false;
//
// button38
//
this->button38->BackColor = System::Drawing::Color::Red;
this->button38->Location = System::Drawing::Point(100, 225);
this->button38->Name = L"button38";
this->button38->Size = System::Drawing::Size(23, 23);
this->button38->TabIndex = 58;
this->button38->UseVisualStyleBackColor = false;
//
// button39
//
this->button39->BackColor = System::Drawing::Color::Green;
this->button39->Location = System::Drawing::Point(72, 225);
this->button39->Name = L"button39";
this->button39->Size = System::Drawing::Size(23, 23);
this->button39->TabIndex = 57;
this->button39->UseVisualStyleBackColor = false;
&lt; ...截断 - 30k字符限制...&gt;`
答案 0 :(得分:0)
好的,我假设kamisado_main.h
是您的主要表单,因为您在.c++
文件中有主例程。
我看不到整个头文件,但我觉得它看起来很好,我希望你用CLI
选项创建项目。
您必须像这样创建form
变量,否则^
,这应该可以解决所有错误:KamisadoBoard ^ form = gcnew KamisadoBoard;
我不确定您是否可以使用C++/CLI
的本机主例程,如果它不起作用请尝试在kamisado_main.cpp
中使用此代码:
#include "kamisado_main.h"
using namespace Project1;
[STAThreadAttribute]
int main(cli::array<System::String ^> ^args)
{
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);
// Create the main window and run it
Application::Run(gcnew KamisadoBoard ());
return 0;
}