Skip to content

Instantly share code, notes, and snippets.

@cheuerde
Created April 1, 2014 16:08
Show Gist options
  • Save cheuerde/9917298 to your computer and use it in GitHub Desktop.
Save cheuerde/9917298 to your computer and use it in GitHub Desktop.
Template class to std::vector
#include <iostream>
#include <vector>
using namespace std;
template<typename T1>
class test_class{
T1 X;
};
int main(){
test_class<double> W;
test_class<int> Z;
vector<test_class<double> > vec; // this compiles fine, as I specify the class
//vector<test_class> vec; // this is impossible, as test_class is only a template
return 0;
}
@cheuerde
Copy link
Author

cheuerde commented Apr 1, 2014

Ich braue einen Weg um die Template-Class in einen std::vector zu stecken. Dies geht so aber nicht, ich brauche
also einen Workaround. Habe im Netz gelesen, dass eine Parent-class für test_class gehen könnte, und ich einen
vector mit pointern zu dieser Klasse erstellen kann

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment