PJF16

inheritance and overloading

Jan 15th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. /*AndroidPhone erbt von MobilePhone wo << überschrieben wurde und die entsprechenden Getter-Klassen ausprogrammiert sind*/
  2.  
  3. #pragma once
  4. #include "MobilePhone.h"
  5.  
  6. class AndroidPhone: public MobilePhone {
  7. private:
  8.     string AndroidOSVersion;
  9. public:
  10.     AndroidPhone(int index, string number, string version);
  11.     AndroidPhone (string os, MobilePhone mp);
  12.     string getOS();
  13.     friend ostream& operator<<(ostream& out, const AndroidPhone &mp);
  14.  
  15. };
  16.  
  17. --------------
  18.  
  19.  
  20. #include "AndroidPhone.h"
  21.  
  22.  
  23. AndroidPhone::AndroidPhone (int i, string num, string os): AndroidOSVersion(os),MobilePhone(i,num){};
  24. AndroidPhone::AndroidPhone (string os, MobilePhone mp):AndroidOSVersion(os),MobilePhone(mp){};
  25.  
  26. string AndroidPhone::getOS() {
  27.  
  28.     return this->AndroidOSVersion;
  29. }
  30.  
  31. ostream& operator<<(ostream& out, const AndroidPhone& ap) {
  32.     return out << ap.getIndex() << " " << ap.getPhoneNumber() << " " << ap.AndroidOSVersion <<endl;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment