作业

#include
class meter{};
class kilometer{};
class second{};
class minute{};
template  
struct traits_help
{
    static const int radix = 1;
    static const char unit = '\0'; 
};
template <> 
struct traits_help
{
    static const int radix = 1; 
    static const char unit = 'm'; 
};
template <> 
struct traits_help
{
    static const int radix = 1000; 
    static const char unit = 'm'; 
};
template <> 
struct traits_help
{
    static const int radix = 1;
    static const char unit = 'm'; 
};
template <> 
struct traits_help
{
    static const int radix = 60;
    static const char unit = 's'; 
};

template 
class Measurement 
{
private:
    int value;
public:
    Measurement(int value){
        this->value = value;
    }
    Measurement& operator = (const int value)
   {
       this->value = value;
       return *this;
    }
    void description()
    {
        std::cout<value*traits_help::radix;
        std::cout<::unit< m1 = 10;
    Measurement m2 = 10;
    Measurement m3 = 20;
    Measurement m4 = 20;
    Measurement m5 = 20;
    m1.description();
    m2.description();
    m3.description();
    m4.description();
    m5.description();
    return 0;
 }

你可能感兴趣的:(作业)