Advertisement
Maku779

CCS1203_A4_Basic_OutsideConstructor

Dec 7th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement