我正在通过一个代码,我遇到了一些问题,并且能够破解这段代码:
#include <iostream>
#include <stdint.h>
#include <unistd.h>
#include <errno.h>
#include <vector>
#include <sys/types.h>
using namespace std;
class abc {
public:
abc(int x,int y) {
cout << "x:" << x << endl;
cout << "y:" << y << endl;
}
virtual ~abc() {}
enum example {
a = 1,
b = 2,
c = 3,
d = 4
};
};
template<typename T>
class xyz {
public:
void some_func(abc *a) {
cout<<"some_func called"<<endl;
}
};
int main() {}
我想调用函数
some_func()
来自main()
。我该怎么做有人能帮帮我吗?
答案 0 :(得分:3)
您需要创建一个模板类xyz的特殊化对象和一个abc类型的对象。
例如
int main()
{
abc a( 10, 20 );
xyz<int> x;
x.some_func( &a );
}