Question: Please help me to find the problem for c + + thank you. I wrote the code out but it says in my user.cpp and
Please help me to find the problem for c thank you.
I wrote the code out but it says in my user.cpp and main.cpp have some mistakes. Please help me fix it thank you
The Question: Implement THE Operator Overloading for class User
Complete the implementation of the operator overloading for your user.h and user.cpp
bool operatorconst User& const;
bool operator!const User& const;
bool operatorconst User& const;
bool operatorconst User& const;
bool operatorconst User& const;
bool operatorconst User& const;
Implement the istream and ostream for your user.h and user.cpp
friend istream& operator istream& in User& user;
friend ostream& operatorostream& out, User& user;
my answere:
user.h
#include
using namespace std;
class User
public:
bool operatorconst User& const;
bool operator!const User& const;
bool operatorconst User& const;
bool operatorconst User& const;
bool operatorconst User& const;
bool operatorconst User& const;
friend std::istream& operatorstd::istream& in User& user;
friend std::ostream& operatorstd::ostream& out, const User& user;
private:
std::string name;
int age;
;
user.cpp
#include "user.h
User::Userconst std::string& name, int age : namename ageage
bool User::operatorconst User& other const
return name other.name && age other.age;
bool User::operator!const User& other const
return this other;
bool User::operatorconst User& other const
return age other.age age other.age && name other.name;
bool User::operatorconst User& other const
return age other.age age other.age && name other.name;
bool User::operatorconst User& other const
return this other;
bool User::operatorconst User& other const
return this other;
std::istream& operatorstd::istream& in User& user
std::string name;
int age;
in name age;
if in
user Username age;
return in;
std::ostream& operatorstd::ostream& out, const User& user
out user.name user.age;
return out;
main.cpp
#include
#include "user.h
int main
User userEason;
User userjason;
std::cout "User: user std::endl;
std::cout "User: user std::endl;
if user user
std::cout "User and User are equal." std::endl;
else if user user
std::cout "User is older than User std::endl;
else
std::cout "User is younger than User std::endl;
std::cout "Enter a new user: ;
User newUser;
std::cin newUser;
std::cout "New user: newUser std::endl;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
