ここでソリューションを実装する方法がわかりません。
コンパイル時のエラーは次のとおりです。
error: expected unqualified-id before 'void'
error: 'string' in class 'UserDirectory' does not name a type
error: 'string' in class 'UserDirectory' does not name a type
===========
**UserDirectory.cpp**
#include "UserDirectory.h"
#include <iostream>
#include <string>
using namespace std;
UserDirectory::UserDirectory(){
cout << "UserDirectory Constructor created\n\n";
}
UserDirectory::void setName(string x){
name = x;
}
UserDirectory::string getName(){
return name_;
}
UserDirectory::string name;
===========
**UserDirectory.h**
#ifndef USERDIRECTORY_H
#define USERDIRECTORY_H
#include <iostream>
#include <string>
class UserDirectory
{
public:
UserDirectory();
void setName( std::string x );
std::string getName();
private:
std::string name_;
};
#endif // USERDIRECTORY_H
========
**main.cpp**
#include <iostream>
#include <string>
#include "UserDirectory.h"
using namespace std;
int main(){
UserDirectory user1;
string inputName;
cout << "Enter your name: ";
cin >> inputName;
user1.setName( inputName );
cout << "\nYou entered " << user1.getName();
return 0;
} // end main