How to solve inheritance and virtual error from two class | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
0

How to solve inheritance and virtual error from two class

How to make this work (https://www.sololearn.com/en/compiler-playground/cf5D2ah15iO1) ? I am getting error in below code: #include <iostream> class testInt { protected: virtual int valueFromText() const; }; class testDouble { protected: virtual double valueFromText() const; }; template<class T> class test : public testInt, public testDouble { protected: virtual double valueFromText() const override; }; int main() { test<int> obj1; return 0; }

10th Mar 2024, 7:42 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Réponses
+ 3
maybe you need a conditional check? It seems that the compiler cannot determine which method to use. I adapted Solo's typechecking code. https://sololearn.com/compiler-playground/c2YEUS4kMXn4/?ref=app
11th Mar 2024, 3:56 AM
Bob_Li
Bob_Li - avatar
+ 1
Perfect Bob_Li
15th Mar 2024, 7:41 AM
Ketan Lalcheta
Ketan Lalcheta - avatar