if u run following code,Sololearn complier will show Error...But if you run in your PC with other C++ complier,there is no error | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

if u run following code,Sololearn complier will show Error...But if you run in your PC with other C++ complier,there is no error

#include <iostream> using namespace std; class MyClass { public: int s,f; void B(int a,int b){ s=a; f=b; } }; class jkp:public Myclass{ public: int u(){ return(s+f); } }; int main() { jkp h; h.B(2,4); cout<<h.u(); return 0;}

13th Nov 2017, 3:33 PM
Thit Htoo
Thit Htoo - avatar
1 Respuesta
+ 2
You forgot a capital in MyClass when you inherit in jkp, it works fine when you change that. Not sure what kind of compiler you have on your pc if it allows this code to compile.
13th Nov 2017, 3:44 PM
Dennis
Dennis - avatar