fork(3) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int DAYS = 0x08;
  5.  
  6. class Date
  7. {
  8. private:
  9. uint8_t day, month, year;
  10.  
  11. public:
  12. Date():day(1), month(1), year(00) {} // Initialisierungsliste mit konstante Parameterwerten
  13. // Initialisierungsliste über parametrisierten Konstruktor
  14. Date(uint8_t _day, uint8_t _month, uint8_t _year):day(_day), month(_month), year(_year) {}
  15.  
  16. uint8_t GetDay(); // Methode
  17. };
  18.  
  19. uint8_t Date::GetDay()
  20. {
  21. return day;
  22. }
  23.  
  24. class DateString : public Date
  25. {
  26. public:
  27. DateString():Date() {}
  28. DateString(uint8_t _day, uint8_t _month, uint8_t _year): Date(_day, _month, _year) {}
  29.  
  30. int GetDay(int xy) { return 0; } // Compiler error: no matching function
  31. };
  32.  
  33. int main()
  34. {
  35. DateString date1; // Instanziierung mit Standard Konstruktor und
  36. DateString date2(18,4,15); // mit parametrisierten Konstruktor
  37.  
  38. printf("Day 1: %d\n", date1.GetDay()); // Verwenden der Methode GetDay aus Klasse Date
  39. printf("Day 2: %d\n", date2.GetDay());
  40. return 0;
  41. }
  42.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:38:37: error: no matching function for call to 'DateString::GetDay()'
  printf("Day 1: %d\n", date1.GetDay());  // Verwenden der Methode GetDay aus Klasse Date
                                     ^
prog.cpp:38:37: note: candidate is:
prog.cpp:30:6: note: int DateString::GetDay(int)
  int GetDay(int xy) { return 0; }  //  Compiler error: no matching function
      ^
prog.cpp:30:6: note:   candidate expects 1 argument, 0 provided
prog.cpp:39:37: error: no matching function for call to 'DateString::GetDay()'
  printf("Day 2: %d\n", date2.GetDay());
                                     ^
prog.cpp:39:37: note: candidate is:
prog.cpp:30:6: note: int DateString::GetDay(int)
  int GetDay(int xy) { return 0; }  //  Compiler error: no matching function
      ^
prog.cpp:30:6: note:   candidate expects 1 argument, 0 provided
stdout
Standard output is empty