fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class sample
  5. {
  6. protected:
  7. int a,b;
  8. public:
  9. void setvalue()
  10. { a=25; b=40; }
  11.  
  12. float mean(sample );
  13. };
  14. float mean(sample )
  15. {
  16. return float(float a +b)/2.0;
  17. }
  18. int main() {
  19. sample x;
  20. x.setvalue();
  21. cout<<"mean vaue= "<<mean(x)<<"\n";
  22. // your code goes here
  23. return 0;
  24. }
Compilation error #stdin compilation error #stdout 0s 3340KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘float mean(sample)’:
prog.cpp:16:9: error: expected primary-expression before ‘float’
  return float(float a +b)/2.0;
         ^
prog.cpp:16:9: error: expected ‘;’ before ‘float’
prog.cpp:16:9: error: expected primary-expression before ‘float’
prog.cpp:16:9: error: expected ‘;’ before ‘float’
prog.cpp:17:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
stdout
Standard output is empty