template <typename Type> class Set {
Type value;
public:
Set();
Set(Type const &value): value(value) {}
operator Type &() {return value;}
operator Type const &() const {return value;}
bool operator == (Set const &other) {return value == other.value;}
};
template <typename Type> class Ring: public Set<Type> {
public:
Ring(): Set<Type>() {}
Ring(Type const &value): Set<Type>(value) {}
Ring operator +(Ring const &other) {return Ring((Type)*this + (Type)other);}
Ring operator -(Ring const &other) {return Ring((Type)*this - (Type)other);}
Ring operator *(Ring const &other) {return Ring((Type)*this * (Type)other);}
};
#include <iostream>
int main() {
Ring<int> a(1), b(2);
Ring<double> x(1.4), y(2.8);
std::cerr << (int)(a+b) << ", " << (double)(x*y) << std::endl;
return 0;
}
Если Вы уже зарегистрированы на Портале - войдите в систему, если Вы еще не регистрировались - пройдите простую процедуру регистрации.