Car myCar("Toyota", "Camry", 2023)


Download 0.68 Mb.
Sana08.05.2023
Hajmi0.68 Mb.
#1446852
Bog'liq
zuxra


O’ZBEKISTON RESPUBLIKASI RAQAMLI TEXNOLOGIYALAR VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI QARSHI FILIALI


TT va KT FAKULTETI
TT 12-22 GURUH TALABASI QURBONTURDIYEVA ZUXRANING
DASTURLASH 2 FANIDAN

1- AMALIY ISHI


Bajardi: Qurbonturdiyeva Zuxra


Qabul qildi: Axmedova N
QARSHI

#include


#include

using namespace std;

class Vehicle {
public:
string brand;
string model;
int year;
virtual void start() = 0;
};

class Car : public Vehicle {


public:
Car(string b, string m, int y) {
brand = b;
model = m;
year = y;
}
void start() {
cout << "The car engine is started." << endl;
}
void drive() {
cout << "Driving the " << brand << " " << model << " car." << endl;
}
};

class Motorcycle : public Vehicle {


public:
Motorcycle(string b, string m, int y) {
brand = b;
model = m;
year = y;
}
void start() {
cout << "The motorcycle engine is started." << endl;
}
void drive() {
cout << "Riding the " << brand << " " << model << " motorcycle." << endl;
}
};

int main() {


Car myCar("Toyota", "Camry", 2023);
Motorcycle myMotorcycle("Harley-Davidson", "Breakout", 2023);

myCar.start();


myCar.drive();

myMotorcycle.start();


myMotorcycle.drive();

return 0;


}

Download 0.68 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling