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
String C++;包括字符串_String_C++ Cli - Fatal编程技术网

String C++;包括字符串

String C++;包括字符串,string,c++-cli,String,C++ Cli,嘿,我正在尝试创建Windows窗体应用程序,但我在定义字符串时遇到了问题 Fam.cpp #include "Fam.h" #include "iostream" #include "string" using namespace std; using namespace Project1; [STAThread] int main(array<System::String ^> ^args) { Application::EnableVisualStyles();

嘿,我正在尝试创建Windows窗体应用程序,但我在定义字符串时遇到了问题

Fam.cpp

#include "Fam.h"
#include "iostream"
#include "string"

using namespace std;
using namespace Project1; 

[STAThread]
int main(array<System::String ^> ^args)
{
    Application::EnableVisualStyles();
    Application::SetCompatibleTextRenderingDefault(false);
    Application::Run(gcnew Fam());
    return 0;
}
这里是我得到的错误

错误1错误C2146:语法错误:缺少“;”在标识符“a”之前
错误2错误C4430:缺少类型说明符-假定为int。注释:C++ 不支持默认的int

我也试过换一根绳子;到std::字符串a;但后来我发现了这些错误:

错误1错误C2039:“字符串”:不是“std”的成员
错误2错误C2146:语法错误:缺少“;”在标识符“a”之前
错误3错误C4430:缺少类型说明符-假定为int。注释:C++ 不支持默认的int


嗯,你必须在你的头上包括字符串,因为那是你使用它的地方

家庭的一部分

#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;


    int IloscBD1=0, IloscBD2=0, IloscPD1, IloscPD2, Suma, I, J, Punkty, P1, P2, P3, P4, P5, P6, Druzyna;
    string a;
#pragma once
#include <string>

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;


    int IloscBD1=0, IloscBD2=0, IloscPD1, IloscPD2, Suma, I, J, Punkty, P1, P2, P3, P4, P5, P6, Druzyna;
    std::string a;

}
#pragma一次
#包括
命名空间项目1{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
int IloscBD1=0,IloscBD2=0,IloscPD1,IloscPD2,Suma,I,J,Punkty,P1,P2,P3,P4,P5,P6,Druzyna;
std::字符串a;
}

嗯,您必须在标题中包含字符串,因为这是您使用它的地方

家庭的一部分

#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;


    int IloscBD1=0, IloscBD2=0, IloscPD1, IloscPD2, Suma, I, J, Punkty, P1, P2, P3, P4, P5, P6, Druzyna;
    string a;
#pragma once
#include <string>

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;


    int IloscBD1=0, IloscBD2=0, IloscPD1, IloscPD2, Suma, I, J, Punkty, P1, P2, P3, P4, P5, P6, Druzyna;
    std::string a;

}
#pragma一次
#包括
命名空间项目1{
使用名称空间系统;
使用名称空间System::ComponentModel;
使用名称空间系统::集合;
使用命名空间System::Windows::Forms;
使用名称空间System::Data;
使用名称空间系统::绘图;
int IloscBD1=0,IloscBD2=0,IloscPD1,IloscPD2,Suma,I,J,Punkty,P1,P2,P3,P4,P5,P6,Druzyna;
std::字符串a;
}
使用
而不是
来包围您的
标准库:
库包含使用
而不是
来包围您的
标准库:
库包含