Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string.h>
- #include <string>
- using namespace std;
- class Automobile{
- public:
- char* Brand;
- int Count;
- int Power;
- Automobile(){
- Count = 0;
- Power = 0;
- Brand = NULL;
- }
- Automobile(int _Count, int _Power, char* _Brand) {
- Count = _Count;
- Power = _Power;
- Brand = _Brand;
- }
- void display(){
- cout << Count << endl << Power << endl << Brand << endl;
- }
- void changeBrand(char* newBrand) {
- Brand = newBrand;
- }
- ~Automobile(){
- }
- };
- class Truck: public Automobile{
- public:
- int Capacity;
- int Body;
- Truck() : Automobile(){
- Capacity = 0;
- Body = 0;
- }
- Truck(int _Capacity, int _Body, int _Count, int _Power, char* _Brand) : Automobile(_Count, _Power, _Brand) {
- Power = _Power;
- Brand = _Brand;
- }
- void changeCapacity(int newCapacity) {
- Capacity = newCapacity;
- }
- void display(){
- cout << Count << endl << Power << endl << Brand << endl << Capacity << endl << Body << endl;
- }
- };
- int main() {
- char brand1[] = "Ab";
- char brand2[] = "Ba";
- Automobile Am(1, 1, brand1);
- Automobile Am1();
- Am.changeBrand(brand2);
- Am.display();
- Truck Tr(2, 2, 1, 1, brand2);
- Truck Tr1();
- Tr.changeBrand(brand1);
- Tr.changeCapacity(3);
- Tr.display();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement