fork download
  1. template <class T>
  2. struct Table
  3. {
  4. T getCell()
  5. {
  6. T c;
  7. c.setTable(this);
  8. }
  9. };
  10.  
  11. struct MyTable;
  12.  
  13. struct Cell
  14. {
  15. void setTable(MyTable *tbl)
  16. {
  17.  
  18. }
  19. };
  20.  
  21. struct MyTable : public Table<Cell>
  22. {
  23.  
  24. };
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.  
  29. MyTable t;
  30. t.getCell();
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘T Table<T>::getCell() [with T = Cell]’:
prog.cpp:30:15:   required from here
prog.cpp:7:9: error: invalid conversion from ‘Table<Cell>* const’ to ‘MyTable*’ [-fpermissive]
prog.cpp:15:10: error:   initializing argument 1 of ‘void Cell::setTable(MyTable*)’ [-fpermissive]
prog.cpp:8:5: warning: no return statement in function returning non-void [-Wreturn-type]
stdout
Standard output is empty