매개 변수의 값에 따라 다른 클래스 개체를 반환하는 함수를 작성하고 싶습니다. 반환하는 클래스 객체는 템플릿 처리됩니다. 함수에 대한 템플릿 인수로 클래스 이름을 지정합니다.C++ 함수 반환 형식을 템플릿으로 사용
template< class T >
static T FindClassObjects(int var){
if(var==1)
return T<float>(var);
else
return T<int>(var);
이 작업을 수행 할 수 있습니까?
_C++에서 매개 변수에 따라 다른 유형을 반환 해 봅니다. 흠 ... [데이터에 따라 다른 데이터 유형 반환 (C++)] 가능한 복제본 (https://stackoverflow.com/questions/930932/returning-different-data-type-depending-on-the-data-c) 또는 [매개 변수에 따라 유형 반환] (https://stackoverflow.com/questions/30088983/returning-a-type-depending-on-the-parameter) –