Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays visual c+中的字符串数组+;形式_Arrays_String_C++ Cli - Fatal编程技术网

Arrays visual c+中的字符串数组+;形式

Arrays visual c+中的字符串数组+;形式,arrays,string,c++-cli,Arrays,String,C++ Cli,我在Microsoft Visual Studio中创建了空的C++/CLI表单 我想做的是把汽车品牌放在一个阵列中,把汽车模型放在另一个阵列中。 然后我会画一个品牌,把它贴在标签上,一个是该品牌的车型,另外三个是其他品牌的车型 在我的表格中,我想创建两个数组: String brands[7]={"Mercedes","Opel","Toyota","Fiat","Audi","Renault","Volkswagen"}; String models[7][5]={{"Benz","Vito

我在Microsoft Visual Studio中创建了空的C++/CLI表单

我想做的是把汽车品牌放在一个阵列中,把汽车模型放在另一个阵列中。 然后我会画一个品牌,把它贴在标签上,一个是该品牌的车型,另外三个是其他品牌的车型

在我的表格中,我想创建两个数组:

String brands[7]={"Mercedes","Opel","Toyota","Fiat","Audi","Renault","Volkswagen"};
String models[7][5]={{"Benz","Vito","AMG","Klasa A","Klasa E"},
                     {"Astra","Corsa","Insignia","Zafira","Mokka"},
                     {"Avensis","Corolla","Yaris","Auris","RAV4"},
                     {"126p","Panda","Punto","500","Tipo"},
                     {"A4","A6","Q7","R8","A7"},
                     {"Megane","Captur","Scenic","Kadjar","Espace"},
                     {"Golf","Passat","Tiguan","Beetle","Touran"}};
我无法将其放在MyForm.h文件中的任何位置,我遇到E2022错误。 你会建议我什么简单的解决方案

#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>
    /// Podsumowanie informacji o MyForm
    /// </summary>
    public ref class MyForm : public System::Windows::Forms::Form
    {
    public:
        MyForm(void)
        {
            InitializeComponent();
            //
            //TODO: W tym miejscu dodaj kod konstruktora
            //
        }


    protected:
        /// <summary>
        /// Wyczyść wszystkie używane zasoby.
        /// </summary>
        ~MyForm()
        {
            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::Label^  label1;
    String marki[7]={"Mercedes","Opel","Toyota","Fiat","Audi","Renault","Volkswagen"};
    String modele[7][5]={{"Benz","Vito","AMG","Klasa A","Klasa E"},
                     {"Astra","Corsa","Insignia","Zafira","Mokka"},
                     {"Avensis","Corolla","Yaris","Auris","RAV4"},
                     {"126p","Panda","Punto","500","Tipo"},
                     {"A4","A6","Q7","R8","A7"},
                     {"Megane","Captur","Scenic","Kadjar","Espace"},
                     {"Golf","Passat","Tiguan","Beetle","Touran"}};

    private:
        /// <summary>
        /// Wymagana zmienna projektanta.
        /// </summary>
        System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Wymagana metoda obsługi projektanta — nie należy modyfikować 
        /// zawartość tej metody z edytorem kodu.
        /// </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->label1 = (gcnew System::Windows::Forms::Label());
            this->SuspendLayout();
            // 
            // button1
            // 

            this->button1->Location = System::Drawing::Point(12, 108);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(147, 23);
            this->button1->TabIndex = 1;
            this->button1->UseVisualStyleBackColor = true;
            // 
            // button2
            // 
            this->button2->Location = System::Drawing::Point(178, 108);
            this->button2->Name = L"button2";
            this->button2->Size = System::Drawing::Size(146, 23);
            this->button2->TabIndex = 1;
            this->button2->UseVisualStyleBackColor = true;
            // 
            // button3
            // 
            this->button3->Location = System::Drawing::Point(12, 183);
            this->button3->Name = L"button3";
            this->button3->Size = System::Drawing::Size(147, 23);
            this->button3->TabIndex = 1;
            this->button3->UseVisualStyleBackColor = true;
            // 
            // button4
            // 
            this->button4->Location = System::Drawing::Point(178, 183);
            this->button4->Name = L"button4";
            this->button4->Size = System::Drawing::Size(146, 23);
            this->button4->TabIndex = 1;
            this->button4->UseVisualStyleBackColor = true;
            // 
            // button5
            // 
            this->button5->Location = System::Drawing::Point(178, 250);
            this->button5->Name = L"button5";
            this->button5->Size = System::Drawing::Size(146, 23);
            this->button5->TabIndex = 1;
            this->button5->Text = L"Nastepne";
            this->button5->UseVisualStyleBackColor = true;
            this->button5->Click += gcnew System::EventHandler(this, &MyForm::button5_Click);
            // 
            // label1
            // 
            this->label1->AutoSize = true;
            this->label1->Location = System::Drawing::Point(140, 28);
            this->label1->Name = L"label1";
            this->label1->Size = System::Drawing::Size(0, 13);
            this->label1->TabIndex = 2;
            // 
            // MyForm
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(361, 306);
            this->Controls->Add(this->label1);
            this->Controls->Add(this->button5);
            this->Controls->Add(this->button4);
            this->Controls->Add(this->button3);
            this->Controls->Add(this->button2);
            this->Controls->Add(this->button1);
            this->Name = L"MyForm";
            this->Text = L"QUIZ";
            this->ResumeLayout(false);
            this->PerformLayout();

        }
#pragma endregion

private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) {

}
};
}
#pragma一次
命名空间项目1{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
/// 
///Podsumowanie informacji o MyForm
/// 
公共引用类MyForm:public System::Windows::Forms::Form
{
公众:
我的表格(作废)
{
初始化组件();
//
//待办事项:W tym miejscu dodaj kod konstruktora
//
}
受保护的:
/// 
///Wyczyśćwszystkie używane zasoby。
/// 
~MyForm()
{
if(组件)
{
删除组件;
}
}
私有:系统::Windows::窗体::按钮^button1;
受保护的:
私有:系统::Windows::窗体::按钮^button2;
私有:系统::Windows::窗体::按钮^button3;
私有:系统::Windows::窗体::按钮^button4;
私有:系统::Windows::窗体::按钮^button5;
私有:系统::Windows::窗体::标签^label1;
字符串marki[7]={“梅赛德斯”、“欧宝”、“丰田”、“菲亚特”、“奥迪”、“雷诺”、“大众”};
字符串modele[7][5]={{“Benz”、“Vito”、“AMG”、“Klasa A”、“Klasa E”},
{“Astra”、“Corsa”、“Insignia”、“Zafira”、“Mokka”},
{“Avensis”、“Corolla”、“Yaris”、“Auris”、“RAV4”},
{“126p”、“熊猫”、“Punto”、“500”、“Tipo”},
{“A4”、“A6”、“Q7”、“R8”、“A7”},
{“梅根”、“卡图尔”、“风景区”、“卡贾尔”、“埃斯佩斯”},
{“高尔夫”、“帕萨特”、“途观”、“甲虫”、“途安”};
私人:
/// 
///Wymagana zmienna projektanta。
/// 
系统::组件模型::容器^组件;
#pragma区域Windows窗体设计器生成的代码
/// 
///Wymagana metoda obsługi项目-nie należy modyfikować
///扎瓦托维奇·梅托迪·埃迪托雷姆·科杜。
/// 
void初始化组件(void)
{
此->按钮1=(gcnew System::Windows::Forms::Button());
此->按钮2=(gcnew System::Windows::Forms::Button());
此->按钮3=(gcnew System::Windows::Forms::Button());
此->按钮4=(gcnew System::Windows::Forms::Button());
此->按钮5=(gcnew System::Windows::Forms::Button());
这->标签1=(gcnewsystem::Windows::Forms::Label());
此->SuspendLayout();
// 
//按钮1
// 
此->按钮1->位置=系统::图纸::点(12108);
此->按钮1->名称=L“按钮1”;
该->按钮1->尺寸=系统::图纸::尺寸(147,23);
此->按钮1->选项卡索引=1;
此->按钮1->UseVisualStyleBackColor=true;
// 
//按钮2
// 
此->按钮2->位置=系统::图纸::点(178108);
此->按钮2->名称=L“按钮2”;
该->按钮2->尺寸=系统::图纸::尺寸(146,23);
此->按钮2->选项卡索引=1;
此->按钮2->UseVisualStyleBackColor=true;
// 
//按钮3
// 
此->按钮3->位置=系统::图纸::点(12183);
此->按钮3->名称=L“按钮3”;
该->按钮3->尺寸=系统::图纸::尺寸(147,23);
此->按钮3->选项卡索引=1;
此->按钮3->UseVisualStyleBackColor=true;
// 
//按钮4
// 
该->按钮4->位置=系统::图纸::点(178183);
此->按钮4->名称=L“按钮4”;
该->按钮4->尺寸=系统::图纸::尺寸(146,23);
此->按钮4->选项卡索引=1;
此->按钮4->UseVisualStyleBackColor=true;
// 
//按钮5
// 
该->按钮5->位置=系统::图纸::点(178250);
此->按钮5->名称=L“按钮5”;
该->按钮5->尺寸=系统::图纸::尺寸(146,23);
此->按钮5->选项卡索引=1;
此->按钮5->文本=L“Nastepne”;
此->按钮5->UseVisualStyleBackColor=true;
this->button5->Click+=gcnewsystem::EventHandler(this,&MyForm::button5\u Click);
// 
//标签1
// 
此->标签1->自动调整大小=真;
此->标签1->位置=系统::图纸::点(140,28);
此->标签1->名称=L“标签1”;
该->标签1->尺寸=系统::图纸::尺寸(0,13);
此->标签1->选项卡索引=2;
// 
//MyForm
// 
这->自动缩放尺寸=系统::图纸::尺寸(6,13);
这->AutoScaleMode=System::Windows::Forms::AutoScaleMode::Font;
这->ClientSize=System::Drawing::Size(361306);
此->控制->添加(此->标签1);
此->控制->添加(此->按钮5);
此->控制->添加(此->按钮4);
此->控制->添加(此->按钮3);
此->控制->添加(此->按钮2);
此->控制->添加(此->按钮1);
此->名称=L“MyForm”;
此->文本=L“测验”;
此->恢复布局(错误);
此->执行布局();
}
#布拉格端区
私有:系统::无效按钮5_单击(系统::对象^sender,系统::事件参数^e){
}
};
}
我在这里
array<String^>^ marki;
array<String^,2>^ modele; //Note the declration 2 next to String^. It is rank of the array. 2 for two dimensional.
//SINGLE DIMENSION ARRAY
marki = gcnew array<String^> {"Mercedes","Opel","Toyota","Fiat","Audi","Renault","Volkswagen"};

//MULTI DIMENSIONAL ARRAY
modele = gcnew array<String^,2> {{"Benz","Vito","AMG","Klasa A","Klasa E"},
                     {"Astra","Corsa","Insignia","Zafira","Mokka"},
                     {"Avensis","Corolla","Yaris","Auris","RAV4"},
                     {"126p","Panda","Punto","500","Tipo"},
                     {"A4","A6","Q7","R8","A7"},
                     {"Megane","Captur","Scenic","Kadjar","Espace"},
                     {"Golf","Passat","Tiguan","Beetle","Touran"}};
        }
String^ test = modele[2,4]; //RAV4