[英]New c++ project at visual studio 2010
I have been working with eclipse for c++ and all was fine.我一直在使用 eclipse for c++,一切都很好。 I want to try visual studio.我想尝试视觉工作室。
I have opened new project:我打开了新项目:
myTree.h:我的树.h:
#ifndef myTree_H_
#define myTree_H_
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <iostream>
class Node {
std::string word;
public:
Node() {
word="TEST";
}
std::string getString() {
return word;
}
}
#endif /* myTree_H_ */
test.cpp:测试.cpp:
#include <stdio.h>
#include <iostream>
#include "myTree.h"
int main() {
Node myNode;
std::cout << myNode.getString() << std::endl;
return 0;
}
but I have build errors:但我有构建错误:
c++\tree2\test.cpp(6): error C2628: 'Node' followed by 'int' is illegal (did you forget a ';'?)
c++\tree2\test.cpp(6): error C3874: return type of 'main' should be 'int' instead of 'Node'
c++\tree2\test.cpp(11): error C2664: 'Node::Node(const Node &)' : cannot convert parameter 1 from 'int' to 'const Node &'
1> Reason: cannot convert from 'int' to 'const Node'
1> No constructor could take the source type, or constructor overload resolution was ambiguous
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I cant understand why is that.. anyone can help?我不明白为什么会这样..任何人都可以帮忙吗?
Joachim's answer (in comments):约阿希姆的回答(在评论中):
You forgot to add a ;
你忘了加一个;
after you class definition.在类定义之后。 The compiler suggests it too.编译器也建议它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.