There are 2 classes A and B. You need to create a container separately for each class through the create method which the template fills the container with a type depending on the parameter of which it was passed.
template <typename T> vector<T> create(tring tipe) { vector<T>test; if (tipe == "a") { test.push_back(A()); } if (tipe == "b") { test.push_back(B()); } return test; } void d() { vector<A>a; vector<B>b; a = create<A>("a"); b = create<B>("b"); } when building this error, 'void std :: vector <A, std :: allocator <_Ty :: push_back (_Ty &&)': cannot convert argument 1 from 'A' to 'const B &'
how to solve it?