Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Num
- {
- private:
- int n;
- string name;
- public:
- Num(string name)
- {
- this->name = name;
- }
- void setN(int n)
- {
- this->n = n;
- this->name = name;
- }
- int getN()
- {
- return this->n;
- }
- void operator=(const Num &nObj)
- {
- cout<<"Alterando: ("<<this->name<<") = "<<nObj.n<<"\n";
- }
- };
- int main()
- {
- Num n1("n1");
- Num n2("n2");
- n1.setN(56);
- cout<<n1.getN()<<"\n";
- n2.setN(45);
- n1 = n2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement