当前位置: 代码迷 >> C++ >> 函数模板
  详细解决方案

函数模板

热度:8558   发布时间:2013-02-26 00:00:00.0
函数模板求助
#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,再试一下。
------解决方案--------------------------------------------------------
大过年的写代码,太辛苦了。。。
双击错误,一看就知道。。。
  相关解决方案