Advertisement
DavidsonDFGL

Verilog monitor like in C++

May 5th, 2016
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Num
  5. {
  6.     private:
  7.         int n;
  8.         string name;
  9.  
  10.     public:
  11.         Num(string name)
  12.         {
  13.             this->name = name;
  14.         }
  15.  
  16.         void setN(int n)
  17.         {
  18.             this->n = n;
  19.             this->name = name;
  20.         }
  21.  
  22.         int getN()
  23.         {
  24.             return this->n;
  25.         }
  26.  
  27.         void operator=(const Num &nObj)
  28.         {
  29.             cout<<"Alterando: ("<<this->name<<") = "<<nObj.n<<"\n";
  30.         }
  31. };
  32.  
  33. int main()
  34. {
  35.     Num n1("n1");
  36.     Num n2("n2");
  37.  
  38.     n1.setN(56);
  39.     cout<<n1.getN()<<"\n";
  40.  
  41.     n2.setN(45);
  42.  
  43.     n1 = n2;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement