What is wrong with this code?
********************Start of The code******************
Code:
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
class Person
{
string name;
public:
Person() {name = "Roger";}
Person(string theName);
string getName() { return name; }
void setName(string theName) { name = theName;}
Person& operator=(const Person& rtSide);
friend istream &operator>>(istream& inStream, Person& personObject);
friend ostream &operator<<(ostream& outStream, const Person& personObject);
};
Person& Person::operator=(const Person &rtSide)
{
name = rtSide.name;
return *this;
}
istream &operator>>(istream& inStream, Person& personObject)
{
cout << "PLEASE ENTER NAME: ";
inStream >> personObject.name;
return inStream;
}
ostream &operator<<(ostream& outStream, const Person& personObject)
{
outStream << personObject.name << '\n';
return outStream;
}
int main()
{
Person rt("Romano"), rt1("Roger");
cout << rt;
return 0;
}
*********************End of Code********************
Can anyone help to figure it our what is wrong with my coding? this are the errors generated by the compiler thanks
--------------------Configuration: assigment3 - Win32 Debug--------------------
Compiling...
as3q3.cpp
C:\Files\assigment3\as3q3.cpp(28) : error C2248: 'name' : cannot access private member declared in class 'Person'
C:\Files\assigment3\as3q3.cpp(8) : see declaration of 'name'
C:\Files\assigment3\as3q3.cpp(34) : error C2248: 'name' : cannot access private member declared in class 'Person'
C:\Files\assigment3\as3q3.cpp(8) : see declaration of 'name'
C:\Files\assigment3\as3q3.cpp(41) : error C2593: 'operator <<' is ambiguous
Error executing cl.exe.
as3q3.obj - 3 error(s), 0 warning(s)
[code][/code]tagged by Salem