fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3. class LandTract()
  4. {
  5. int length;
  6. int width;
  7. int area(int,int);
  8. public:
  9. bool friend isEqualSize(LandTract ,LandTract);
  10. }
  11. int LandTract()::area(int l,int w)
  12. {
  13. return l*w;
  14. }
  15. bool isEqualSize(LandTract ab1,LandTract ab2)
  16. {
  17. if(ab1.area(ab1.length,ab1.width)==ab2.area(ab2.length,ab2.width));
  18. return true;
  19. else
  20. return false;
  21. }
  22. int main()
  23. {
  24. LandTract ob1;LandTract ob2;
  25. cout<<"enter dimension of first tract";
  26. cin>>ob1.length>>ob1.width;
  27. cout<<"enter dimension of second tract ";
  28.  
  29. cin>>ob2.length>>ob2.width;
  30. bool a=isEqualSize(ob1,ob2);
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:3:17: error: expected unqualified-id before ')' token
 class LandTract()
                 ^
prog.cpp:11:16: error: expected initializer before '::' token
 int LandTract()::area(int l,int w)
                ^
prog.cpp: In function 'bool isEqualSize(LandTract, LandTract)':
prog.cpp:15:28: error: 'ab1' has incomplete type
 bool isEqualSize(LandTract ab1,LandTract ab2)
                            ^
prog.cpp:3:7: note: forward declaration of 'class LandTract'
 class LandTract()
       ^
prog.cpp:15:42: error: 'ab2' has incomplete type
 bool isEqualSize(LandTract ab1,LandTract ab2)
                                          ^
prog.cpp:3:7: note: forward declaration of 'class LandTract'
 class LandTract()
       ^
prog.cpp:19:5: error: 'else' without a previous 'if'
     else 
     ^
prog.cpp: In function 'int main()':
prog.cpp:24:15: error: aggregate 'LandTract ob1' has incomplete type and cannot be defined
     LandTract ob1;LandTract ob2;
               ^
prog.cpp:24:29: error: aggregate 'LandTract ob2' has incomplete type and cannot be defined
     LandTract ob1;LandTract ob2;
                             ^
stdout
Standard output is empty