Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- class Car
- {
- private:
- int productYear;
- char regNumber[16];
- char brandAndModel[31];
- char owner[31];
- public:
- //Deafault Constructor
- Car();
- //Constructor
- Car(int = 0, char* = '\0', char* = '\0', char* = '\0');
- //Copy Constructor
- //Operator=
- //Destructor
- //Getters
- int getProductYear() const;
- char& getRegNumber() const;
- char& getBrandAndModel() const;
- char& getOwner() const;
- //Setters
- void changeProductYear(int);
- void changeRegNumber(char*);
- void changeBrandAndModel(char*);
- void changeOwner(char*);
- //Others
- void print();
- void comparator(const Car&, const Car&);
- };
- Car::Car()
- {
- productYear = 0;
- strcpy(regNumber, "None");
- strcpy(brandAndModel, "None");
- strcpy(owner, "None");
- }
- Car::Car(int _year, char* _regnumber, char* _model, char* _owner)
- : productYear(_year)
- {
- strcpy(regNumber, _regnumber);
- strcpy(brandAndModel, _model);
- strcpy(owner, _owner);
- }
- int Car::getProductYear() const
- {
- return productYear;
- }
- void Car::print()
- {
- cout << "Year of product: " << productYear << endl;
- cout << "Registartion number: " << regNumber << endl;
- cout << "Brand and model: " << brandAndModel << endl;
- cout << "Owner: " << owner << endl;
- }
- int main() {
- Car car1(1999, "OB7408BH", "Volkswagen", "Radoslav");
- car1.print();
- Car car11();
- cout << car11.getProductYear() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement