Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. class Automobile{
  8. public:
  9. char* Brand;
  10. int Count;
  11. int Power;
  12.  
  13. Automobile(){
  14. Count = 0;
  15. Power = 0;
  16. Brand = NULL;
  17. }
  18.  
  19. Automobile(int _Count, int _Power, char* _Brand) {
  20. Count = _Count;
  21. Power = _Power;
  22. Brand = _Brand;
  23. }
  24.  
  25. void display(){
  26. cout << Count << endl << Power << endl << Brand << endl;
  27. }
  28.  
  29. void changeBrand(char* newBrand) {
  30. Brand = newBrand;
  31. }
  32.  
  33. ~Automobile(){
  34.  
  35. }
  36. };
  37.  
  38. class Truck: public Automobile{
  39. public:
  40. int Capacity;
  41. int Body;
  42.  
  43. Truck() : Automobile(){
  44. Capacity = 0;
  45. Body = 0;
  46. }
  47.  
  48. Truck(int _Capacity, int _Body, int _Count, int _Power, char* _Brand) : Automobile(_Count, _Power, _Brand) {
  49. Power = _Power;
  50. Brand = _Brand;
  51. }
  52.  
  53. void changeCapacity(int newCapacity) {
  54. Capacity = newCapacity;
  55. }
  56.  
  57. void display(){
  58. cout << Count << endl << Power << endl << Brand << endl << Capacity << endl << Body << endl;
  59. }
  60. };
  61.  
  62. int main() {
  63. char brand1[] = "Ab";
  64. char brand2[] = "Ba";
  65. Automobile Am(1, 1, brand1);
  66. Automobile Am1();
  67. Am.changeBrand(brand2);
  68. Am.display();
  69. Truck Tr(2, 2, 1, 1, brand2);
  70. Truck Tr1();
  71. Tr.changeBrand(brand1);
  72. Tr.changeCapacity(3);
  73. Tr.display();
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement