Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Car {
- private:
- int year;
- string make, model;
- double consumption;
- public:
- Car() {
- // default (empty) constructor
- }
- Car(int _year, string make, string model, double consumption) { // constructor with parameters
- year = _year;
- this->make = make;
- this->model = model;
- this->consumption = consumption;
- }
- Car(const Car & tmp) {
- this->year = tmp.year;
- this->make = tmp.make;
- this->model = tmp.model;
- this->consumption = tmp.consumption;
- }
- Car & operator = (const Car & tmp) { // operator = za dodeluvanje
- this->year = tmp.year;
- this->make = tmp.make;
- this->model = tmp.model;
- this->consumption = tmp.consumption;
- return *this;
- }
- ~Car() {}
- int get_year() {
- return year;
- }
- string get_make() {
- return make;
- }
- string get_model() {
- return model;
- }
- double get_consumption() {
- return consumption;
- }
- void set_year(int _year) {
- this->year = _year;
- }
- void set_make(string _make) {
- this->make = _make;
- }
- void set_model(string _model) {
- this->model = _model;
- }
- void set_consumtion(double _consumption) {
- this->consumption = _consumption;
- }
- };
- int main() {
- Car c(2025, "mercedes", "S", 15);
- Car c2(c);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment