Advertisement
Guest User

Untitled

a guest
Feb 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. #include <iostream.h>
  2. #include <conio.h>
  3. #include <string>
  4.  
  5.  
  6.  
  7. using namespace std;
  8.  
  9. class Vehicle {
  10. private:
  11. string registracijas_numurs;
  12. int rezosanas_gads;
  13. string valsts_razotajs;
  14.  
  15. public:
  16. Vehicle(string, string, int);
  17. Vehicle();
  18. // Vehicle(int, string, string);
  19.  
  20. ~Vehicle() {
  21. cout << "Message from the \"CVehicle\" - destroyed!" << endl;
  22. }
  23. int GetGads() const{
  24. return rezosanas_gads;
  25. };
  26. void SetGads(int x);
  27. string GetRazotajs() const;
  28. void SetRazotajs(string x);
  29. string GetNumurs() const;
  30. void SetNumurs(string x);
  31. void Print() const;
  32. };
  33.  
  34. Vehicle::Vehicle(string numurs, string valsts, int gads){
  35. registracijas_numurs=numurs;
  36. valsts_razotajs=valsts;
  37. rezosanas_gads=gads;
  38. }
  39. Vehicle::Vehicle(): registracijas_numurs("0"), valsts_razotajs("non"),rezosanas_gads(2000) {
  40. }
  41.  
  42. inline void Vehicle::SetGads(int x) {
  43. this->rezosanas_gads = x;
  44. }
  45. inline string Vehicle::GetRazotajs() const{
  46. return valsts_razotajs;
  47. };
  48. inline void Vehicle::SetRazotajs(string x){
  49. valsts_razotajs=x;
  50. };
  51. inline string Vehicle::GetNumurs() const{
  52. return registracijas_numurs ;
  53. };
  54. inline void Vehicle::SetNumurs(string x){
  55. registracijas_numurs=x;
  56. };
  57.  
  58.  
  59. //CoordPoint::CoordPoint() : X(0), Y(0) {
  60. //}
  61.  
  62. //CoordPoint::CoordPoint(int Px, int Py) : X(Px) {
  63. // Y = Py;
  64. //}
  65. /*inline int CoordPoint::GetY() const {
  66. return Y;
  67. }
  68. inline void CoordPoint::SetY(int Y) {
  69. this->Y = Y;
  70. }*/
  71. inline void Vehicle::Print() const {
  72. cout << "Registracijas numurs = " << registracijas_numurs << ", Razosanas gads = " << rezosanas_gads<<", Razots - "<< valsts_razotajs<<endl;
  73. }
  74.  
  75. void main(void) {
  76. Vehicle bmw("BM9766", "LV", 1992);
  77. Vehicle *audi= new Vehicle("DE1234", "Germany", 1998);
  78. Vehicle *golf;
  79. golf = new Vehicle();//("GO5435", "USA", 1765);
  80. Vehicle skoda= Vehicle("Sk4321", "IT", 1777);
  81.  
  82. skoda.Print();
  83. golf->Print();
  84. bmw.Print();
  85. audi->Print();
  86.  
  87. skoda.SetRazotajs("LT");
  88. bmw.SetGads(3999);
  89. audi->SetNumurs("qwe1234");
  90.  
  91. skoda.Print();
  92. golf->Print();
  93. bmw.Print();
  94. audi->Print();
  95.  
  96. /*
  97. CoordPoint CP1, CP2(1,2), CP3 = CoordPoint(3, 4),
  98. *CP4 = new CoordPoint(5, 6), *CP5;
  99. CP5 = new CoordPoint(7, 8);
  100.  
  101. clrscr();
  102.  
  103. CP1.Print();cout<<endl;
  104. CP1.SetX(1);
  105. CP1.CoordPoint::Print();cout<<endl;
  106.  
  107. cout << endl << "**************" << endl << endl;
  108.  
  109. (*CP4).Print();cout<<endl;
  110. CP4->SetY(9);
  111. CP4->Print();cout<<endl;
  112. (*CP4).CoordPoint::Print();cout<<endl;
  113. CP5->CoordPoint::Print();cout<<endl;
  114.  
  115. delete CP4;
  116. delete CP5;
  117. */
  118. delete golf;
  119. delete audi;
  120. system("pause");
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement