fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. class Plant {
  5. private:
  6. char Type[10];
  7. // your code goes here
  8.  
  9. };//end class Plant
  10.  
  11. class Fruit: public Plant {
  12.  
  13. // your code goes here
  14.  
  15. };//end class Fruit
  16.  
  17.  
  18. int main() {
  19. Plant a("Maple");
  20. a.print();
  21. Plant b("Maple");
  22.  
  23. if (a == b)
  24. printf("a and b are equal\n");
  25. else
  26. printf("a and b are not equal\n");
  27. if (a != b)
  28. printf("a and b are not equal\n");
  29. else
  30. printf("a and b are equal\n");
  31.  
  32. Fruit c("Apple","sweet");
  33. c.print();
  34. Fruit d("Apple","sweet");
  35.  
  36. if (c == d)
  37. printf("c and d are equal\n");
  38. else
  39. printf("c and d are not equal\n");
  40. if (c != d)
  41. printf("c and d are not equal\n");
  42. else
  43. printf("c and d are equal\n");
  44.  
  45. if (a == c)
  46. printf("a and c are equal\n");
  47. else
  48. printf("a and c are not equal\n");
  49. if (a != c)
  50. printf("a and c are not equal\n");
  51. else
  52. printf("a and c are equal\n");
  53.  
  54. if (c == a)
  55. printf("c and a are equal\n");
  56. else
  57. printf("c and a are not equal\n");
  58. if (a != c)
  59. printf("c and a are not equal\n");
  60. else
  61. printf("c and a are equal\n");
  62.  
  63. return 0;
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:19:9: error: no matching constructor for initialization of 'Plant'
  Plant a("Maple");
        ^ ~~~~~~~
prog.cpp:4:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [6]' to 'const Plant' for 1st argument
class Plant {
      ^
prog.cpp:4:7: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided
prog.cpp:21:9: error: no matching constructor for initialization of 'Plant'
  Plant b("Maple");
        ^ ~~~~~~~
prog.cpp:4:7: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'const char [6]' to 'const Plant' for 1st argument
class Plant {
      ^
prog.cpp:4:7: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 1 was provided
prog.cpp:32:9: error: no matching constructor for initialization of 'Fruit'
  Fruit c("Apple","sweet");
        ^ ~~~~~~~~~~~~~~~
prog.cpp:11:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class Fruit: public Plant {
      ^
prog.cpp:11:7: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 2 were provided
prog.cpp:34:9: error: no matching constructor for initialization of 'Fruit'
  Fruit d("Apple","sweet");
        ^ ~~~~~~~~~~~~~~~
prog.cpp:11:7: note: candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided
class Fruit: public Plant {
      ^
prog.cpp:11:7: note: candidate constructor (the implicit default constructor) not viable: requires 0 arguments, but 2 were provided
4 errors generated.
stdout
Standard output is empty