While trying to pass a value to a constructed, I kept getting errors about that the constructed can't accept the value, is that because of the main class ? :
#include <iostream>
#include <string>
using std::cout;
using std::endl;
Class GettingVal{
public:
GettingVal(string z){
setName(z);
}
void setName(string x){
name = x;
}
string getName(){
return name;
}
private:
string name;
}
using namespace std;
int main()
{
GettingVal Name("Hiiiiiii");
std::cout << Name.getName();
}
Here is the error I get after compiling the project :
error: ‘Name’ was not declared in this scope
std::cout << Name.getName();