Results 1 to 6 of 6
Thread: C++
Hybrid View
-
20th May 2011 17:01 #1
C++
,
:
?Code:char mqsto_trugvane[60]; char mqsto_pristigane[60]; int km; double cena; int chas_trugvane[2]; int chas_pristigane[2]; int data_pristigane[3]; int data_trugvane[3]; int korekten;
:
masiv[0] - mqsto_pristigane
masiv[1] - mqsto_trugvane
..
masiv?
, . ? char?.
-
20th May 2011 17:42 #2
-
20th May 2011 17:43 #3Have no fear ike iz here.
CPU Cx486DLC@40MHz, RAM 4MB, VGA Trident 512KB, HDD Conner 160MB, Monitor 14" Color
-
20th May 2011 17:50 #4
.
mqsto_trugvane info[0]Code:class bilet{ struct info{ char mqsto_trugvane[60]; char mqsto_pristigane[60]; int km; double cena; int chas_trugvane[2]; int chas_pristigane[2]; int data_pristigane[3]; int data_trugvane[3]; int korekten; }; bilet(){ info info; } };
info[0] , info.mqsto_trugvane, ?
.
-
20th May 2011 18:44 #5
Operator overloading, google .
:
c++ char* ...Code:// : char* operator[] (const int nIndex); // : char** bilet::operator [](const int nIndex) { if (b == 0) return &mqsto_trugvane; }
[0] char*, [1] char*Last edited by Lan; 20th May 2011 at 19:02.
I mourn thee by dusk | I mourn thee by dawn
Crave for thy gloss | to seek the silent glades beyond
-
24th May 2011 00:36 #6Registered User
Join Date: Sep:2009
Location: Shumen
Posts: 12
, . .
Code:#include <iostream> using namespace std; class bilet{ struct info{ char mqsto_trugvane[60]; char mqsto_pristigane[60]; int km; double cena; int chas_trugvane[2]; int chas_pristigane[2]; int data_pristigane[3]; int data_trugvane[3]; int korekten; }; public: bilet() { all = new info [100]; count=0; } bilet(long maximum) { all = new info [maximum]; count=0; } ~bilet() { delete[] all; } void set_bilet(char* mqsto_trygvane, char* mqsto_pristigane) { strcpy(all[count].mqsto_trugvane,mqsto_trygvane); strcpy(all[count].mqsto_pristigane,mqsto_pristigane); count++; } void get_bilet() { for (int i=0; i<count; i++) cout<<all[i].mqsto_trugvane<<' '<<all[i].mqsto_pristigane<<endl; } private: long max_data; info *all; long count; }; void main () { bilet *bi = new bilet(); bi->set_bilet("Paris","New York"); bi->set_bilet("London","Tokyo"); bi->get_bilet(); }




Reply With Quote
Lenovo ThinkPad 15 IdeaPad 15
5th May 2023, 22:16 in