[ create a new paste ] login | about

Link: http://codepad.org/G8tlCQKz    [ raw code | output | fork ]

C++, pasted on Jun 13:
#include <iostream>
using namespace std;
 
class SimpleCircle           
{
public:
    SimpleCircle();
    SimpleCircle(int);
 
    SimpleCircle(const SimpleCircle & rhs);// <= Конструктор копирования
 
    SimpleCircle& operator=(SimpleCircle & rhs)
    { cout<< "operator=\n"; return *this;}
 
    SimpleCircle& operator=(const SimpleCircle & rhs)
    { cout<< "operator=(const)\n"; return *this;}
 
 
    ~SimpleCircle();
 
    SimpleCircle operator++();
    SimpleCircle operator++(int);
 
    void SetRadius(int);
    int GetRadius();
 
    void Hello()const{ cout<<"Hello! I am const\n";  }
    void Hello(){ cout<<"Hello! I am not const\n";  }
private:
    //int *itsRadius;
};


SimpleCircle :: SimpleCircle(){}
SimpleCircle :: SimpleCircle(int input){}
SimpleCircle :: SimpleCircle(const  SimpleCircle & rhs)
{
    cout<<"copy\n";
}
SimpleCircle :: ~SimpleCircle(){}
SimpleCircle SimpleCircle :: operator++(){ return *this;}
 
 
SimpleCircle SimpleCircle :: operator++(int)
{
    cout<<"BEGIN\n";
    SimpleCircle temp(*this);
    cout<<"END\n";
    return temp;
}

int main()
{    
    SimpleCircle a(10), b(20);
 
    //(b++).Hello();
//     ++a;++b;
//     a++;b++;
     a=b++;//<= Здесь ошибка
//     a=++b;//<= и здесь.
}


Output:
1
2
3
4
5
BEGIN
copy
END
copy
operator=(const)


Create a new paste based on this one


Comments: