fbpx

Rép :1-1=2

Accueil Forums Détente Jeux Devinettes 1-1=2 Rép :1-1=2

#2396

ça compte:

#include

template
class Type
{
T value;

public:
Type(T value):value(value) {};

T operator-(const Type& t2)
{
return this->value+t2.value;
}

friend std::ostream& operator << (std::ostream& os, const Type& t);
};

std::ostream& operator << (std::ostream& os, const Type& t)
{
os << t.value;
return os;
}

int main()
{
Type x(1);
Type y(1);

std::cout << x << "-" << y << "=" << x-y << std::endl;
}
[/CODE]

[quote]
./op
1-1=2[/quote][CODE]#include

template
class Type
{
T value;

public:
Type(T value):value(value) {};

T operator-(const Type& t2)
{
return this->value+t2.value;
}

friend std::ostream& operator << (std::ostream& os, const Type& t);
};

std::ostream& operator << (std::ostream& os, const Type& t)
{
os << t.value;
return os;
}

int main()
{
Type x(1);
Type y(1);

std::cout << x << "-" << y << "=" << x-y << std::endl;
}
[/CODE]

Quote:
./op
1-1=2