fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Cow
  5. {
  6. public:
  7. int id;
  8.  
  9. Cow()
  10. {
  11. id = 0;
  12. }
  13.  
  14. void setId(int id)
  15. {
  16. this->id = id;
  17. }
  18. };
  19.  
  20. void change(int i, Cow cow)
  21. {
  22. cow.setId(i);
  23. }
  24.  
  25. int main() {
  26. Cow* hemda = new Cow();
  27.  
  28. change(70, *cow);
  29.  
  30. cout << hemda->id;
  31.  
  32. delete hemda;
  33. }
  34.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
2
10
42
11
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:28: error: ‘cow’ was not declared in this scope
stdout
Standard output is empty