1
我只是有一個頭文件,並和.cpp文件我只是傳遞一個值的功能,但它給了我一個錯誤這個C++程序有什麼問題?
的main.c
#include "me.h"
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int main()
{
me("http");
}
me.h
#ifndef ME_H_
#define ME_H_
#include <string.h>
class me {
public:
me(std::string u);
virtual ~me();
};
#endif /* ME_H_ */
me.cpp
#include "me.h"
#include <iostream>
#include <string.h>
using namespace std;
me::me(std::string u) {
// TODO Auto-generated constructor stub
cout << "help";
}
me::~me() {
// TODO Auto-generated destructor stub
}
我得到一個錯誤
In file included from ../src/me.cpp:8:
../src/me.h:13: error: expected ‘)’ before ‘u’
../src/me.cpp:12: error: prototype for ‘me::me(std::string)’ does not match any in class ‘me’
../src/me.h:11: error: candidates are: me::me(const me&)
../src/me.h:11: error: me::me()
make: *** [src/me.o] Error 1
@Erik是正確的。和往常一樣,第一個錯誤信息是需要注意的一點:編譯器說它在me.h行中混淆了,聲明`me(std :: string u);` – aschepler 2011-02-17 21:27:51