首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

函数模板

2013-02-19 
函数模板求助#include iostream template typename Tclass vector{public: vector() {first0second

函数模板求助

#include <iostream>
 

template <typename T>
class vector
{
public:
 vector()
 {
first=0;
second=0;
 }
  vector(T first, T second)
 {
  first=a;
   second=b;
 }
  T display();
private:
double first;
 double second;
};
template <typename T>
  T vector<T>::displaly()
  {
  std::cout<<"("<<first<<","<<second<<endl;
  return first;
  return second;
  }
  void main()
  {
   vector<int> a(9,8);
   a.display();

  }

编译器说a.display() is not a member of Vector<T> 
[解决办法]
displaly 改成 display,再试一下。
[解决办法]
大过年的写代码,太辛苦了。。。
双击错误,一看就知道。。。

热点排行