Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在C+中使用模板时类型不匹配+;_C++_Templates - Fatal编程技术网

C++ 在C+中使用模板时类型不匹配+;

C++ 在C+中使用模板时类型不匹配+;,c++,templates,C++,Templates,我已经编写了一个类模板(在文件abc.hpp中): 问题出在哪里?如何解决?您试图将函数分配给vstart,而不是调用函数的结果: int vstart = my_var.GetStart(); // <- I added () here int vend = my_var.GetEnd(); // <- and here. int-vstart=my_var.GetStart()// #include <iostream> #include "abc.hpp"

我已经编写了一个类模板(在文件
abc.hpp
中):


问题出在哪里?如何解决?

您试图将函数分配给vstart,而不是调用函数的结果:

int vstart = my_var.GetStart(); // <- I added () here
int vend = my_var.GetEnd();     // <- and here.
int-vstart=my_var.GetStart()//
#include <iostream>
#include "abc.hpp"

int main (){
  Edge<int> my_var (1,2);
  Edge<int> my_var2 (1,3);
  int vstart = my_var.GetStart;
  int vend = my_var.GetEnd;
  cout << my_var << " : " << my_var2 << endl;
}
argument of type `int(Edge<int>::)() const` does not match `int`
int vstart = my_var.GetStart(); // <- I added () here
int vend = my_var.GetEnd();     // <- and here.