I wanna pass a struct like this:
template<typename T>
struct mystruct{
T a;
T b;
typename std::vector<T> v1;
};
to a function like this:
template<typename T>
inline void myfunc(const typename mystruct<T> &struct1){
std::cout<<struct1.a<<'\t'
<<struct2.b<<'\n';
for(int i =0; i<struct1.v1.size(); i++)
std::cout<<struct1.v1[i]<<'\n';
}
I know myfunc()
must be sth. wrong, how can I correctly do this? Many thanks!
#include <iostream>
#include <vector>
int main(){
mystruct<float> strc1;
strc1.a = 1.0;
strc1.b = 2.0;
strc1.v1.push_back(1.0);
strc1.v1.push_back(2.0);
myfunc(strc1);
return 0;
}