[ create a new paste ] login | about

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

C++, pasted on Nov 26:
#include<iostream>
class check_int
{
public:
    check_int& operator=( int i )
    {
        val = ( 0 < i ) ? i : 0;
        return *this;
    }
    operator int() const
    {
        return val;
    }
private:
    int val;
};

class crood
{
public:
    check_int X,Y;
}; 

int main()
{
    crood tmp;
    tmp.X =  200;
    tmp.Y = -100;
    std::cout << tmp.X << "," << tmp.Y << std::endl;
    return 0;
}


Output:
1
200,0


Create a new paste based on this one


Comments: