C++模板:为什么答案是0 0 1 9 8而不是0.0 0.0 1 9 8呢?

阅读下面程序,写出输出结果。

#include <iostream>

using namespace std;

 

template <class Type>

class Test

{

public:

       Test(Type a = 0, Type b = 0, Type c = 0):z(c) {     x = a; y = b; }

       void Print()

       {

              cout << x << endl;

              cout << y << endl;

       }

       void Print() const

       {

              cout << z << endl;

       }

 

private:

       Type x, y;

       const Type z;

};

 

int main()

{

       Test<float> t1;

       t1.Print();

 

       Test<int> t2(1, 9, 6);

       t2.Print();

 

       const Test<double> t3(0, 6, 1.8);

       t3.Print();

 

       return 0;

}

上面程序的输出结果为:

0即使作为浮点数输出cout也是输出0,除非你强行要求带1位小数才会0.0