SHARE
TWEET

CCS1203_A4_Basic_OutsideConstructor

Maku779 Dec 7th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class myCar
  6. {
  7.   public:
  8.     string brand, model;
  9.     int year;
  10.     myCar(string b, string m, int y);
  11. };
  12.  
  13. myCar::myCar(string b, string m, int y)
  14. {
  15.     brand = b;
  16.     model = m;
  17.     year = y;
  18. }
  19.  
  20. int main()
  21. {
  22.     myCar myObj1("BMW", "X5", 1990);
  23.     myCar myObj2("Ford", "Mustang", 1969);
  24.  
  25.     cout << "--------------------------" << endl;
  26.     cout << "- BRAND - MODEL   - YEAR -" << endl;
  27.     cout << "--------------------------" << endl;
  28.     cout << "- " << myObj1.brand << "   - " << myObj1.model << "      - " << myObj1.year << " - " << endl;
  29.     cout << "- " << myObj2.brand << "  - " << myObj2.model << " - " << myObj2.year << " - " << endl;
  30.     cout << "--------------------------" << endl;
  31.  
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top