I am looking for a way to pass an instance of a templated class to another class.
The context: I am working with a library (that I don't want to edit for now) containing a templated class of this style:
//my templated class
template<int a, int b> //non-type
class Tclass{
...
}
I would like to use this class in combination with another library I am currently writing myself. My library contains a class that requires an instance of the templated class. It looks somewhat like this:
//another class that I want to receive the instance of Tclass
class A{
private:
Tclass _in; //I want this private variable to hold the passed instance
public:
void A(const Tclass<> & in); //constructor that receives the instance of Tclass
}
//The constructor code:
void A(const Tclass<> & in){
_in = in; //assign the passed instance to a hidden variable
}
My main file then would look somewhat like this:
//my main file
int main() {
Tclass<1,5> tclass; //initialize the templated class with two integers
A a(tclass); //pass the Tclass instance to another class
return 0;
}
I saw that on the forum there are a few hints how to do so for a templated class where the variable type is templated, but in my case I have an integer that is templated.
Thank you in advance for your ideas and help.