fork download
  1. #include <iostream>
  2. #include <iostream>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. struct Date {
  9. short year;
  10. short month;
  11. short day;
  12. };
  13.  
  14. struct Stuff {
  15. Date birth;
  16. };
  17.  
  18. struct ListElement {
  19. struct Stuff* person; // Pointer to struct Stuff
  20. struct ListElement* next; // Pointer to the next Element
  21. };
  22.  
  23. int main() {
  24. short birth_year;
  25. short birth_month;
  26. short birth_day;
  27. cin >> birth_year;
  28. cin >> birth_month;
  29. cin >> birth_day;
  30.  
  31.  
  32. ListElement* const start = new ListElement();
  33. ListElement* actual = start;
  34.  
  35. actual->person = new Stuff();
  36. actual->person->birth.year = new short[sizeof(birth_year)]; // Conversion Error
  37.  
  38. delete start;
  39. delete actual;
  40. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:36:29: error: invalid conversion from ‘short int*’ to ‘short int’ [-fpermissive]
  actual->person->birth.year = new short[sizeof(birth_year)]; // Conversion Error
                             ^
stdout
Standard output is empty