I was going through a code where I encountered some problem and was able to crack this piece of code:
#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() {}
I want to call the function
some_func()
from main()
. How should I do that. Can somebody help me with this??
You need to create an object of some specialization of the template class xyz and an object of the type abc.
For example
int main()
{
abc a( 10, 20 );
xyz<int> x;
x.some_func( &a );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.