#include #include uint Base = 10; template class SmartPointer { public: explicit SmartPointer(T* to_hold) : _p(to_hold) { std::cout << "Common sp ctor" << std::endl; } ~SmartPointer() { delete _p; } private: T* _p; }; template <> class SmartPointer { public: explicit SmartPointer(int* to_hold) : _p(to_hold) { std::cout << "Spec sp ctor" << std::endl; } ~SmartPointer() { std::cout << "ooo, int " << *_p << " is to be crashed."; delete _p; } private: int* _p; }; int main1() { SmartPointer pd(new double(3.5)); SmartPointer pi(new int(44)); return 0; } template class BigInteger { public: BigInteger() = default; BigInteger(BigInteger low, uint up) : _low(low), _up(up) {} std::string ToString() const { std::string answer; answer.append(std::to_string(_up)); answer.append(_low.ToString()); return answer; } BigInteger operator-() const { return {-_low, _up}; } // template // BigInteger operator+(const BigInteger& right) const; private: BigInteger _low; uint _up = 0; }; template <> class BigInteger<1> { public: BigInteger() = default; BigInteger(uint digit, bool is_positive) : _digit(digit), _is_positive(is_positive) {} std::string ToString() const { return std::to_string(_digit); } BigInteger<1> operator-() const { return {_digit, !_is_positive}; } private: uint _digit = 0; bool _is_positive = true; }; /*class BigIntegerWithSign { private: BigInteger bi; bool sign; }; */ int main() { BigInteger<5> bi1; // BigInteger<5> bi2; // bi1 + bi2; BigInteger<5> bi2(-bi1); std::cout << bi2.ToString() << std::endl; return 0; }