这个C++程序有什么问题?

new*_*ewb 1 c++

我只有一个头文件和一个.cpp文件,我只是将值传递给函数,但它给了我一个错误

main.c中

#include "me.h"
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;

int main()
{
    me("http");
}
Run Code Online (Sandbox Code Playgroud)

me.h

#ifndef ME_H_
#define ME_H_
#include <string.h>
class me {
public:
    me(std::string u);
    virtual ~me();
};

#endif /* ME_H_ */
Run Code Online (Sandbox Code Playgroud)

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
}
Run Code Online (Sandbox Code Playgroud)

我收到了一个错误

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
Run Code Online (Sandbox Code Playgroud)

Eri*_*rik 21

#include <string> 代替 #include <string.h>

string.h是C字符串头,可以在C++中访问 <cstring>

<string> 是定义的C++头 std::string