if语句中的模板声明

时间:2016-12-21 15:55:56

标签: c++ templates if-statement

我试图了解C ++模板。我没有太多编程方面的专家,所以如果我说或写一些愚蠢的东西,我很抱歉。 我有以下模板

template <class C> class A
{
   public:
   A(){};
   // some functions here
}

在我的主要功能中,我想要一些东西

int a;

// a function that evaluates if a must be set to 1 or 0

if(a==1)
{
  A  var<Class1>();
}else{
  A  var<Class2>();
}

我知道这是不可能做到的,但我问我怎么能达到这样的目的。

0 个答案:

没有答案
相关问题