fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. struct S { };
  6. struct R {
  7. void foo(S* x){} // declared with a pointer as we wanted=
  8. };
  9.  
  10. int main() {
  11. R r;
  12. S* t=new S[15]; // t is a pointer, which can be used as a table of 15 elemeents
  13. r.foo(&t[3]); //ok
  14. r.foo(t[3]); //ouch !!!
  15.  
  16. // your code goes here
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 3456KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:14:12: error: no matching function for call to 'R::foo(S&)'
  r.foo(t[3]);  //ouch !!!
            ^
prog.cpp:7:10: note: candidate: void R::foo(S*)
     void foo(S* x){}    // declared with a pointer as we wanted=
          ^
prog.cpp:7:10: note:   no known conversion for argument 1 from 'S' to 'S*'
stdout
Standard output is empty