为什么它不编译,但在cpp.sh上编译
Why it dont compile, but compile on cpp.sh
我有那个QT:
Qt Creator 4.1.0基于Qt 5.7.0 (MSVC 2013, 32位)
Built on Aug 24 2016 14:56:50
下一个代码:
#include <iostream>
using namespace std;
[enter image description here][1]
// универсальный полиморфизм (шаблон)
template <typename T>
class value {
public:
T val;
};
// динамический полиморфизм
class var {
public:
virtual char type(){return 'U';}
};
class Int:public var {
public:
char type(){return 'I';}
};
class String:public var {
public:
char type(){return 'S';}
};
class Float:public var {
public:
char type(){return 'F';}
};
class M:public var{};
std::string gettype(var* opt){
if (opt->type() == 'U'){
return "unknown";
} else if (opt->type() == 'I') {
return "int";
} else if (opt->type() == 'S'){
return "string";
} else if (opt->type() == 'F'){
return "float";
}
}
int main(int argc, char *argv[]){
// универсальный полиморфизм
value<int> n;
n.val = 5;
value<string> s;
s.val = "text";
cout << n.val << endl;
cout << s.val << endl;
// динамический полиморфизм
var* a = new Int();
var* b = new String();
var* c = new Float();
var* x = new M();
cout << gettype(a) << endl;
return 0;
}
它在cpp.sh上运行良好,但在我的QT上win8.1不工作。
"二元" & lt; & lt;":无法找到操作数类型为" STD:: string "的操作符(或无法接受转换)"
您可能需要使用:
包含string.h#include <string>
然后我将删除[enter image description here][1]
行,我不知道它是做什么的,它不是c++代码。
相关文章:
- 如何使用线程类编译 cpp 文件?
- 在Windows中为Android编译.cpp文件
- 编译 cpp 代码
- 我可以使用 cmake/make 编译我使用的所有且仅编译 cpp/hpp 文件吗?
- 使用Linaro工具链编译CPP文件时出现错误
- 编译 CPP 应用程序时出错。 "error: 'posix_memalign' was not declared in this scope"
- 在 ubuntu 的 shell 上编译 cpp 程序时出现问题
- 使用CMAKE软件编译.CPP文件
- CMAKE:阅读和编译CPP文件的动态生成列表
- 如何编译CPP文件以进行芯片Attiny85
- WMware 编译 cpp 文件 linux
- 如何始终使用Eclipse编译cpp文件
- 如何编译 cpp,然后将其链接到共享库
- CMake + Cuda:在 Cuda-mode (--x=cu) 下编译 cpp 文件
- 编译 cpp-netlib 源代码时出错
- 在什么条件下必须编译 cpp 代码并将其链接到 exe 中
- 批处理文件,用于在任何PC上编译.cpp文件
- 编译cpp时不使用相应的头
- 无法编译 cpp-netlib 示例
- 在Android-ndk(r7)中编译.cpp文件时如何打开"C++0X"实验标准?