samedi 6 novembre 2021

How to instantiate a class from the stack with different constructors?

I need to create a class instance from the stack, but depending on a variable I need to call it with different constructors

  class A
    {
     public:
      A(std::string str);
      A(int value)
    };

void main(void)
{
 bool condition = true;

 A class_a {condtion ? "123" : 456};
   
}

But I can't get it to compile.

Aucun commentaire:

Enregistrer un commentaire