Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #pragma once
  2. class Parent {
  3. protected:
  4. char *childName;
  5.  
  6. public:
  7. Parent ( char* _childName ) {
  8. childName = _childName;
  9. }
  10.  
  11. char *getChildName () {
  12. return childName;
  13. }
  14. };
  15.  
  16. class Alpha: public Parent {
  17. protected:
  18. const char* alphaName = "ALPHA";
  19.  
  20. public:
  21. Alpha (): Parent ( alphaName ) {
  22. Serial.print ( F ( "My name is " ) );
  23. Serial.println ( getChildName () );
  24. }
  25. };
  26.  
  27. class Beta: public Parent {
  28. protected:
  29. const char* betaName = "BETA";
  30.  
  31. public:
  32. Beta (): Parent ( betaName ) {
  33. Serial.print ( F ( "My name is " ) );
  34. Serial.println ( getChildName () );
  35. }
  36. };
  37.  
  38. Alpha *alpha;
  39. Beta *beta;
  40. void setup () {
  41. Serial.begin ( 115200 );
  42. while (!Serial.availableForWrite ()) {}
  43.  
  44. alpha = new Alpha ();
  45. beta = new Beta ();
  46. }
  47.  
  48. void loop() {}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement