C++ return different objects

前端 未结 3 1172
别跟我提以往
别跟我提以往 2021-01-29 12:30

i have a big problem.. I wonna select the Storage Service via a wrapper class. The returning value must be an object within the storage service class. I pasted my current approa

3条回答
  •  天涯浪人
    2021-01-29 13:16

    Error return Auto in test(),it's return two different types. Change by StorageTemplate*

    class controller {
        public:
            StorageTemplate* test(int select) {
                if( select == 1)
                {
                    return new SQL(); 
                } else {
                    return new REDIS();
                }
            }
    };
    

提交回复
热议问题