首页 新闻 会员 周边

以下程序如何修改才能正常运行?

0
[待解决问题]
 1   #include <iostream>
 2   using namespace std; 
 3   template <typename T>  
 4      
 5      
 6      class complex 
 7       { 
 8       public: 
 9           complex(T x, T y){m_x=x;m_y=y;}
10      private:
11               T m_x;     T m_y;   
12               friend ostream& operator<<<T>(ostream &s,const complex<T> &t);
13   };
14   
15                    template <typename T> 
16                   ostream & operator<<(ostream &s,const complex<T> &t)
17                    {    s<<t.m_x<<"+"<<t.m_y<<"i";
18                     return s;
19                    }
20               int main()
21               {         complex<double> tt1(1.9, 2.8);     
22                       std::cout << tt1 << endl;     
23                       complex<int> tt2(1, 2);     
24                       std::cout << tt2 << endl;
25               }
foxing的主页 foxing | 初学一级 | 园豆:5
提问于:2012-06-21 23:45
< >
分享
所有回答(1)
0

你现在的结果是什么?你期望的结果是什么?还是这段程序根本就不能运行?

无之无 | 园豆:5095 (大侠五级) | 2012-06-22 07:11

运行出错,不懂解决。

支持(0) 反对(0) foxing | 园豆:5 (初学一级) | 2012-06-25 18:48

@itjy: 错误信息是什么?

支持(0) 反对(0) 无之无 | 园豆:5095 (大侠五级) | 2012-06-25 22:22
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册