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;}
1 Odpowiedź
+ 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.