473,385 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

deprecated conversion from string constant to char

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<iomanip>
  3. #include<iostream>
  4. #include<conio.h>
  5. #include<string.h>
  6. #include<vector>
  7. #include<list>
  8. #include"Movie.h"
  9. using namespace std;
  10.  
  11.  
  12.  
  13. //Passanger class
  14. class Passenger{
  15. private:
  16. int bookingRefNo;
  17. char name[50];
  18. int numAdult;
  19. int numChildren;
  20. int numFlights;
  21. double totalPrice;
  22.  
  23. public:
  24. Passenger();
  25.  
  26. //setter methods retun type
  27. void setBookingRef();
  28. void setName(char inName[50]);
  29. void setNumAdult(int noAdult);
  30. void setNumChildren(int noChild);
  31. void setNumFlight(int noFlight);
  32. void setTotalPrice(double inTotalPrice);
  33.  
  34. //getter method initialization
  35. int getBookingRef();
  36. char * getName();
  37. int getNumAdult();
  38. int getNumChildren();
  39. int getNumFlight();
  40. double getTotalPrice();
  41. };
  42. //setter methods
  43. Passenger::Passenger(){
  44. setBookingRef();
  45. }
  46.  
  47. void Passenger::setBookingRef(){
  48. static int count=500;
  49. count++;
  50.  
  51. bookingRefNo=count;
  52. }
  53. void Passenger::setName(char inName[50]){
  54. strcpy(name,inName);
  55. }
  56. void Passenger::setNumAdult(int noAdult){
  57. numAdult = noAdult;
  58. }
  59. void Passenger::setNumChildren(int noChild){
  60. numChildren = noChild;
  61. }
  62. void Passenger::setNumFlight(int noFlight){
  63. numFlights = noFlight;
  64. }
  65. void Passenger::setTotalPrice(double inTotalPrice){
  66. totalPrice = inTotalPrice;
  67. }
  68. //getter methods
  69. int Passenger::getBookingRef(){
  70. return bookingRefNo;
  71. }
  72. char* Passenger::getName(){
  73. return name;
  74. }
  75. int Passenger::getNumAdult(){
  76. return numAdult;
  77. }
  78. int Passenger::getNumChildren(){
  79. return numChildren;
  80. }
  81. int Passenger::getNumFlight(){
  82. return numFlights;
  83. }
  84. double Passenger::getTotalPrice(){
  85. return totalPrice;
  86. }
  87.  
  88. class Flight{
  89. //initialization
  90. private:
  91. int flightNo;
  92. char orgin[50];
  93. char destination[50];
  94. char date[50];
  95. char deparR[50];
  96. double price;
  97. int childPerc;
  98. vector<Movie> movieList;
  99.  
  100. public:
  101.  
  102. Flight();
  103. Flight(char InOrgin[50], char InDesi[50], char InDate[50], char InDeparr[50], double inPrice, int ChildPerc);
  104. void SetflightNo();
  105. void SetOrgin(char InOrgin[50]);
  106. void SetDesti(char InDesti[50]);
  107. void SetDate(char InDate[50]);
  108. void SetDeparr(char InDeparr[50]);
  109. void SetPrice(double InPrice);
  110. void SetChildPerc(int InChildPerc);
  111.  
  112. int  GetflightNo();
  113. char* GetOrgin();
  114. char* GetDesti();
  115. char* GetDate();
  116. char* GetDeparr();
  117. double GetPrice();
  118. int GetChildPerc();
  119. void addMovie(Movie objMov);
  120.  
  121.  
  122. };
  123. Flight::Flight(){
  124. SetflightNo();
  125. SetOrgin("null");
  126. SetDesti("null");
  127. SetDeparr("null");
  128. SetPrice(0.0);
  129. SetChildPerc(0);
  130. }
  131. Flight::Flight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int InChildPerc){
  132. SetflightNo();
  133. SetOrgin(InOrgin);
  134. SetDesti(InDesi);
  135. SetDeparr(InDeparr);
  136. SetPrice(inPrice);
  137. SetChildPerc(InChildPerc);
  138. }
  139. //setter methods
  140. void Flight::SetflightNo(){
  141. static int flightCount=100;
  142. flightCount++;
  143. flightNo = flightCount;
  144.  
  145. }
  146.  
  147. void Flight:: SetOrgin(char InOrgin[50]){
  148. strcpy(orgin,InOrgin);
  149. }
  150.  
  151. void Flight::SetDesti(char InDesti[50]){
  152. strcpy(destination,InDesti);
  153. }
  154. void Flight::SetDate(char InDate[50]){
  155. strcpy(date,InDate);
  156. }
  157. void Flight::SetDeparr(char InDeparr[50]){
  158. strcpy(deparR,InDeparr);
  159. }
  160. void Flight::SetPrice(double InPrice){
  161. price = InPrice;
  162. }
  163. void Flight::SetChildPerc(int InChildPerc){
  164. childPerc = InChildPerc;
  165. }
  166. //getter methods
  167. int Flight::GetflightNo(){
  168. return flightNo;
  169. }
  170.  
  171. char* Flight:: GetOrgin(){
  172. return orgin;
  173. }
  174.  
  175. char* Flight::GetDesti(){
  176. return destination;
  177. }
  178. char* Flight::GetDate(){
  179. return date;
  180. }
  181. char* Flight::GetDeparr(){
  182. return deparR;
  183. }
  184.  
  185. double Flight::GetPrice(){
  186. return price;
  187. }
  188.  
  189. int Flight::GetChildPerc(){
  190. return childPerc;
  191. }
  192.  
  193. void Flight::addMovie(Movie objMov){
  194. movieList.push_back(objMov);
  195. //Business Flight Class
  196. class BusinessFlight : public Flight{
  197. private:
  198. double rate;
  199.  
  200. public:
  201.  
  202. BusinessFlight();
  203. BusinessFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc, double inRate);
  204. void SetRate(double InRate);
  205. double GetRate();
  206. Passenger Book(Passenger obj);
  207. };
  208.  
  209. BusinessFlight::BusinessFlight():Flight(){
  210. SetRate(0.0);
  211. }
  212.  
  213. BusinessFlight::BusinessFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc, double 
  214.  
  215. inRate):Flight(InOrgin,InDesi,InDate,InDeparr,inPrice,ChildPerc)
  216. {
  217. SetRate(inRate);
  218. }
  219.  
  220.  
  221. Passenger BusinessFlight::Book(Passenger obj){
  222. double adultPrice;
  223. double childPrice;
  224. double totalPrice;
  225. adultPrice = obj.getNumAdult() * GetPrice() * GetRate();
  226. childPrice = obj.getNumChildren() * (double) GetChildPerc()/100 * GetRate();
  227. totalPrice = adultPrice + childPrice;
  228. obj.setTotalPrice(totalPrice);
  229. obj.setNumFlight(GetflightNo());
  230. return obj;
  231. }
  232. //setter methods
  233. void BusinessFlight::SetRate(double InRate){
  234. rate = InRate;
  235. }
  236. //getter methods
  237. double BusinessFlight::GetRate(){
  238. return rate;
  239. }
  240.  
  241. //class economy flight
  242. class EconomyFlight : public Flight{
  243. private:
  244. public:
  245. EconomyFlight();
  246.     EconomyFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc);
  247. Passenger Book(Passenger obj);
  248. };
  249.  
  250. EconomyFlight::EconomyFlight(){
  251.  
  252. }
  253.  
  254. Passenger EconomyFlight::Book(Passenger obj){
  255. double adultPrice;
  256. double childPrice;
  257. double totalPrice;
  258. adultPrice = obj.getNumAdult() * GetPrice();
  259. childPrice = obj.getNumChildren() * (double) GetChildPerc()/100;
  260. totalPrice = adultPrice + childPrice;
  261. obj.setTotalPrice(totalPrice);
  262. obj.setNumFlight((int)GetflightNo());
  263. return obj;
  264. }
  265. EconomyFlight::EconomyFlight(char *InOrgin, char *InDesi, char *InDate, char *InDeparr, double inPrice, int ChildPerc):Flight
  266.  
  267. (InOrgin,InDesi,InDate,InDeparr,inPrice,ChildPerc){
  268.  
  269. }
  270.  
  271.  
  272.  
  273. //Travel Agent Class
  274. class TrevelAgent{
  275. private:
  276. char *name;
  277. list<Passenger> ListPassenger;
  278. list<BusinessFlight> ListBusiness;
  279. list<EconomyFlight> ListEconomy;
  280.  
  281. public:
  282. void setName(char *InName);
  283. char* getName();
  284. void addEconomy(EconomyFlight objEcono);
  285. void addBusiness(BusinessFlight objBusiness);
  286. void addPassenger(Passenger objPassenger);
  287. void FlightList();
  288. void PassengerList();
  289. void DeleteFlight(int FlightNo);
  290. void DeletePassneger(int Pid);
  291.     void BookFlight(int PID , int FID);
  292. };
  293.  
  294. void TrevelAgent::addEconomy(EconomyFlight objEcono){
  295. ListEconomy.push_back(objEcono);
  296. }
  297.  
  298. void TrevelAgent::addBusiness(BusinessFlight objBusiness){
  299. ListBusiness.push_front(objBusiness);
  300. }
  301.  
  302. void TrevelAgent::addPassenger(Passenger objPassenger){
  303. ListPassenger.push_back(objPassenger);
  304. }
  305. //setter methods
  306. void TrevelAgent::setName(char *InName){
  307. name= InName;
  308. }
  309. //getter methods
  310. char* TrevelAgent::getName(){
  311. return name;
  312. }
  313.  
  314. void TrevelAgent::FlightList(){
  315. cout<<"ID"<<setw(10)<<"Orgin"<<setw(20)<<"Destination"<<setw(10)<<"Date"<<setw(10)<<"Price\n";
  316. list<BusinessFlight>::iterator dis;
  317. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  318. BusinessFlight b = *dis;
  319.  
  320. cout<<b.GetflightNo()<<setw(10)<<b.GetOrgin()<<setw(20)<<b.GetDesti()<<setw(10)<<b.GetDate()<<setw(10)<<b.GetPrice()
  321.  
  322. <<"\n";
  323. }
  324. list<EconomyFlight>::iterator itrEcon;
  325. for(itrEcon=ListEconomy.begin();itrEcon!=ListEconomy.end();itrEcon++){
  326. EconomyFlight e = *itrEcon;
  327. cout<<e.GetflightNo()<<setw(10)<<e.GetOrgin()<<setw(20)<<e.GetDesti()<<setw(10)<<e.GetDate()<<setw(10)<<e.GetPrice()
  328.  
  329. <<"\n";
  330. }
  331.  
  332. }
  333.  
  334. void TrevelAgent::PassengerList(){
  335. cout<<"Booking id"<<setw(10)<<"Name"<<setw(20)<<"No Adult"<<setw(10)<<"No of Child"<<setw(10)<<"Price\tFlightID\n";
  336. list<Passenger>::iterator itrPasn;
  337. for(itrPasn=ListPassenger.begin(); itrPasn!=ListPassenger.end();itrPasn++){
  338. Passenger p = *itrPasn;
  339. cout<<p.getBookingRef()<<setw(10)<<p.getName()<<setw(20)<<p.getNumAdult()<<setw(10)<<p.getNumChildren()<<setw
  340.  
  341. (10)<<p.getTotalPrice()<<"\t"<<p.getNumFlight()<<"\n";
  342. }
  343. }
  344.  
  345. void TrevelAgent::DeleteFlight(int FlightNo){
  346. list<BusinessFlight>::iterator dis;
  347. list<BusinessFlight>::iterator currentpos;
  348. int flag =0;
  349. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  350. BusinessFlight b = *dis;
  351. int myFli = b.GetflightNo();
  352. if(FlightNo == myFli ){
  353. currentpos = dis;
  354. flag = 1;
  355. }
  356. }
  357.  
  358. list<EconomyFlight>::iterator itrEcon;
  359. list<EconomyFlight>::iterator EconCurrent;
  360. for(itrEcon=ListEconomy.begin(); itrEcon!=ListEconomy.end();itrEcon++){
  361. EconomyFlight e = *itrEcon;
  362. int myFli = e.GetflightNo();
  363. if(FlightNo == myFli ){
  364. EconCurrent = itrEcon;
  365. flag = 2;
  366. }
  367. }
  368.  
  369. if (flag==1){
  370. char ch;
  371. cout << "Do you want Delete Flight " << FlightNo << " :";
  372. cin >> ch;
  373. if(ch=='y'||ch=='Y'){
  374. ListBusiness.erase(currentpos);
  375. cout <<"Deleted......." <<endl;
  376. }
  377. }else{
  378. cout << "Could not found !!!!!"<<endl;
  379. }
  380.  
  381. if (flag==2){
  382. char ch;
  383. cout << "Do you want Delete Flight " << FlightNo << " :";
  384. cin >> ch;
  385. if(ch=='y'||ch=='Y'){
  386. ListEconomy.erase(EconCurrent);
  387. cout <<"Deleted......." <<endl;
  388. }
  389. }else{
  390. cout << "Could not found !!!!!"<<endl;
  391. }
  392. }
  393.  
  394. void TrevelAgent::DeletePassneger(int PID){
  395. list<Passenger>::iterator itrPas;
  396. list<Passenger>::iterator currentpos;
  397. int flag =0;
  398. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  399. Passenger p = *itrPas;
  400. int myFli = p.getBookingRef();
  401. if(PID == myFli ){
  402. currentpos = itrPas;
  403. flag = 1;
  404. }
  405. }
  406.  
  407.  
  408. if (flag==1){
  409. char ch;
  410. cout << "Do you want Delete Passenger " << PID << " :";
  411. cin >> ch;
  412. if(ch=='y'||ch=='Y'){
  413. ListPassenger.erase(currentpos);
  414. cout <<"Deleted......." <<endl;
  415. }
  416. }else{
  417. cout << "Could not found !!!!!"<<endl;
  418. }
  419.  
  420. }
  421.  
  422. void TrevelAgent::BookFlight(int PID , int FID){
  423.  
  424. list<Passenger>::iterator itrPas;
  425.  
  426. Passenger PC ;
  427. int flag =0;
  428. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  429. Passenger p = *itrPas;
  430. int myFli = p.getBookingRef();
  431. if(PID == myFli ){
  432.  
  433. PC = *itrPas;
  434. flag = 1;
  435. }
  436. }
  437.  
  438.  
  439. list<BusinessFlight>::iterator dis;
  440.  
  441. BusinessFlight BC;
  442.  
  443.  
  444. for(dis=ListBusiness.begin(); dis!=ListBusiness.end();dis++){
  445. BusinessFlight b = *dis;
  446. int myFli = b.GetflightNo();
  447. if(FID == myFli ){
  448.  
  449. BC = *dis;
  450. flag = 1;
  451. }
  452. }
  453.  
  454. list<EconomyFlight>::iterator itrEcon;
  455.  
  456. EconomyFlight EC;
  457. for(itrEcon=ListEconomy.begin(); itrEcon!=ListEconomy.end();itrEcon++){
  458. EconomyFlight e = *itrEcon;
  459. int myFli = e.GetflightNo();
  460. if(FID == myFli ){
  461.  
  462. EC  = *itrEcon;
  463. flag = 2;
  464. }
  465. }
  466.  
  467. if (flag==1){
  468.  
  469. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  470. Passenger p = *itrPas;
  471. int myFli = p.getBookingRef();
  472. if(PID == myFli ){
  473.  
  474. *itrPas = BC.Book(PC);
  475.  
  476. }
  477. }
  478. }
  479.  
  480. if (flag==2){
  481.  
  482. for(itrPas=ListPassenger.begin(); itrPas!=ListPassenger.end();itrPas++){
  483. Passenger p = *itrPas;
  484. int myFli = p.getBookingRef();
  485. if(PID == myFli ){
  486.  
  487. *itrPas = EC.Book(PC);
  488.  
  489. }
  490. }
  491. }
  492. }
  493. //Travel Console
  494.  
  495. class TravelConsole{
  496. private:
  497. BusinessFlight *objBusiness;
  498. EconomyFlight *objEconomy;
  499. Flight* objFlght;
  500. Movie *objMovie;
  501. TrevelAgent objAgent;
  502. public:
  503. void CreateBusinessFlight();
  504. void CreateEconomyFlight();
  505. void CreateMovie();
  506. void ListFlight();
  507. void CreatePassenger();
  508. void DeleteFlight();
  509. void DeletePassenger();
  510. void Booking();
  511. TrevelAgent getTrevelAgent();
  512. };
  513.  
  514. TrevelAgent TravelConsole::getTrevelAgent(){
  515. return objAgent;
  516. }
  517.  
  518. void TravelConsole::CreateBusinessFlight(){
  519. char orgin[50];
  520. char destination[50];
  521. char date[50];
  522. char deparr[50];
  523. double price;
  524. int childPercentage;
  525. double rate;
  526. cout<<"Business Flight Detail"<<endl;
  527. cout <<"-------------------------------------"<<endl;
  528. cout << "Enter the Flight Origin  :";
  529. cin >> orgin;
  530. cout << "Enter the Flight Destination :";
  531. cin >> destination;
  532. cout << "Enter Flight Date :";
  533. cin >> date;
  534. cout << "Enter the Depar and Arrival Time (dep 1:00 , arr 3:00):";
  535. cin >> deparr;
  536. cout << "Enter the Price :" ;
  537. cin >> price;
  538. cout << "Enter the Child Percentage :";
  539. cin >> childPercentage;
  540. cout << "Enter the Rate :";
  541. cin >> rate;
  542. BusinessFlight obiBussin;
  543. obiBussin.SetOrgin(orgin);
  544. obiBussin.SetDesti(destination);
  545. obiBussin.SetDate(date);
  546. obiBussin.SetDeparr(deparr);
  547. obiBussin.SetPrice(price);
  548. obiBussin.SetChildPerc(childPercentage);
  549. obiBussin.SetRate(rate);
  550. objAgent.addBusiness(obiBussin);
  551. char ch;
  552. char no='y';
  553. cout <<"Do you want add Movie to this Flight (Y/N) :";
  554. cin >>ch;
  555. if(ch=='y'||ch=='Y'){
  556. while(no!='n'){
  557. CreateMovie();
  558. cout <<"Movied added" <<endl;
  559. cout <<"Do you add another Movie (Y/N) :";
  560. cin >> no;
  561. };
  562. }
  563.  
  564. }
  565.  
  566. void TravelConsole::CreateEconomyFlight(){
  567. char orgin[30];
  568. char destination[30];
  569. char date[30];
  570. char deparr[30];
  571. double price;
  572. int childPercentage;
  573.  
  574. cout<<"Economy Flight Detail"<<endl;
  575. cout <<"-------------------------------------"<<endl;
  576. cout << "Enter the Flight Origin  :";
  577. cin >> orgin;
  578. cout << "Enter the Flight Destination :";
  579. cin >> destination;
  580. cout << "Enter Flight Date :";
  581. cin >> date;
  582. cout << "Enter the Depar and Arrival Time (dep 1:00 , arr 3:00) :";
  583. cin >> deparr;
  584. cout << "Enter the Price :" ;
  585. cin >> price;
  586. cout << "Enter the Child Percentage :";
  587. cin >> childPercentage;
  588.  
  589. EconomyFlight EconoFlight;
  590. EconoFlight.SetOrgin(orgin);
  591. EconoFlight.SetDesti(destination);
  592. EconoFlight.SetDate(date);
  593. EconoFlight.SetDeparr(deparr);
  594. EconoFlight.SetPrice(price);
  595. EconoFlight.SetChildPerc(childPercentage);
  596. objAgent.addEconomy(EconoFlight);
  597.  
  598. char ch;
  599. cout <<"Do you want add Movie to this Flight (Y/N) :";
  600. cin >>ch;
  601. if(ch=='y'||ch=='Y'){
  602. CreateMovie();
  603. cout <<"Movied added" <<endl;
  604. }
  605. }
  606.  
  607. void TravelConsole::CreatePassenger(){
  608. int bookingRef;
  609. char name[50];
  610. int numAdult;
  611. int numChild;
  612. int numFlight;
  613. double totalPrice;
  614.  
  615. cout<<"Create Persion"<<endl;
  616. cout <<"-------------------------------------"<<endl;
  617. cout << "Enter the Name:";
  618. cin >> name;
  619. cout << "Enter Number of Adult :";
  620. cin >> numAdult;
  621. cout << "Enter Number of Children:";
  622. cin >> numChild;
  623. Passenger objPasn;
  624. objPasn.setName(name);
  625. objPasn.setNumAdult(numAdult);
  626. objPasn.setNumChildren(numChild);
  627. objPasn.setNumFlight(0);
  628. objPasn.setTotalPrice(0.0);
  629. objAgent.addPassenger(objPasn);
  630. }
  631.  
  632. void TravelConsole::CreateMovie(){
  633. char title [40];
  634. cout<<"Create Flight"<<endl;
  635. cout <<"-------------------------------------"<<endl;
  636. cout << "Enter Movie Name  :";
  637. cin >> title;
  638. objMovie = new Movie(title);
  639. }
  640.  
  641. void TravelConsole::DeleteFlight(){
  642. int FID;
  643. cout << "Please Enter the Flight No :";
  644. cin >> FID;
  645. objAgent.DeleteFlight(FID);
  646. }
  647.  
  648. void TravelConsole::DeletePassenger(){
  649. int PID;
  650. cout << "Please Enter the Passenger ID:";
  651. cin >> PID;
  652. objAgent.DeletePassneger(PID);
  653. }
  654.  
  655. void TravelConsole::Booking(){
  656. int PID;
  657. int FID;
  658.  
  659. objAgent.PassengerList();
  660. cout << "Select A Passenger :";
  661. cin >> PID;
  662. objAgent.FlightList();
  663. cout << "Select A Select a Flight:";
  664. cin >> FID;
  665. objAgent.BookFlight(PID,FID);
  666. }
  667.  
  668. void TravelConsole::ListFlight(){
  669.  
  670. }
  671.  
  672. int main(){
  673. //main menu
  674. TravelConsole travel;
  675. int v=10;
  676.  
  677. int menuloc;
  678. do{
  679. cout << "MAIN MENU" << endl;
  680. cout << "----------------------" <<endl;
  681. cout <<"1. Create Business Flight " <<endl;
  682. cout <<"2. Create Economy Flight " <<endl;
  683. cout <<"3. Flight List " << endl;
  684. cout <<"4. Create Passenger " <<endl;
  685. cout <<"5. Passenger list " <<endl;
  686. cout <<"6. Delete Flight " << endl;
  687. cout <<"7. Delete Passenger " << endl;
  688. cout <<"8. Booking " << endl;
  689. cout <<"9. Exit " << endl;
  690. cout <<"" << endl;
  691. cout <<"Please Select a Choice: " <<flush;
  692. cin >>menuloc;
  693.  
  694. switch(menuloc){
  695. case 1: {    
  696. travel.CreateBusinessFlight();
  697. break;
  698. }
  699. case 2: {
  700. travel.CreateEconomyFlight();
  701. break;
  702. }
  703.  
  704. case 3:{
  705. travel.getTrevelAgent().FlightList();
  706. break;
  707.   }
  708. case 4:{
  709. travel.CreatePassenger();
  710. break;
  711.   }
  712. case 5:{
  713. travel.getTrevelAgent().PassengerList();
  714. break;
  715.   }
  716. case 6:{
  717. travel.DeleteFlight();
  718. break;
  719.   }
  720. case 7:{
  721. travel.DeletePassenger();
  722. break;
  723.   }
  724. case 8:{
  725. travel.Booking();
  726. break;
  727.   }
  728. case 9:{
  729. return 0;
  730. break;
  731.   }
  732. }
  733.  
  734.  
  735. }while(menuloc!=v);
  736.  
  737. getchar();
  738. system("pause");
  739. return 0;
  740. }
  741.  
  742.  

I am getting the error in Fligh:Flight() when the program is run.
Any help is appreciated!

Thanks
Attached Images
File Type: jpg a.jpg (20.2 KB, 180 views)
Dec 6 '16 #1
2 1734
weaknessforcats
9,208 Expert Mod 8TB
using the str... function from C (strcpy, strstr, etc) are all deprecated in C++ because you should be using the C++ string class plus the old C functions need a \0 to terminate. If they don't find one, they just continue on, corrupt your memory and crash your program.

Beyond that, you are passing the address of local variables around the program. Not good. Use heap allocated variables. Especially the arrays in places like your Flight class. There is no code top prevent array overrun. Typically you would have a string object in your class which handles this problem. If you aren't allowed to do that, you should determine the size of he data to insert in the class object, then allocate that much memory, then copy the data to the allocation. All you need in your class definition is a pointer to the allocation. The effect is to remove all those hard-coded array lengths.
Dec 6 '16 #2
Thanks for the help. ..................
Dec 7 '16 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: G. Peter | last post by:
Hi there, I've a 'funny' error message of my compiler (g++ 2.95.4) that tells me: robot.cpp: In method `Robot::Robot()': robot.cpp:19: warning: deprecated conversion from string constant to...
24
by: Julie | last post by:
I'm re-evaluating the way that I convert from a std::string to char *. (Requirement: the source is a std::string, the usable contents are char *) Here is what I've come up with: #include...
5
by: Anton Pervukhin | last post by:
Hello! Imagine the situation you have a class that interprets the command line of the program you are executing. This class is written by third party and has a main function parse with arguments...
1
by: Paul Steckler | last post by:
I'm using a managed C++ class that wants an unsigned char __gc as input. Is there a way to easily populate that array from a string constant (or wide string constant, etc.)? I'd like to do...
20
by: Peteroid | last post by:
How the heck does one convert a String* to char? Specifically: String* my_string = "HELLO" ; char m_char_array ; m_char_array = my_string ; // error strcpy( m_char_array, my_string ) ; //...
2
by: Alejandro Aleman | last post by:
Hello! i know this may be a newbie question, but i need to convert a string from System::String^ to char*, in the msdn page tells how, but i need to set to /clr:oldSyntax and i dont want it...
10
by: Steve Pope | last post by:
The first of the following functions compiles, the second gives what I think is a spurious error: "cannot convert `const char' to `char *' in assignment". void foo(int m) { char *str; if (m...
3
by: Kevin Frey | last post by:
I am porting Managed C++ code from VS2003 to VS2005. Therefore adopting the new C++/CLI syntax rather than /clr:oldSyntax. Much of our managed code is concerned with interfacing to native C++...
20
by: karthikbalaguru | last post by:
Hi, String constant being modifiable in C++ but, not modifiable in C. that is, In C++, the following example output will be "Mplusplus" char *str1 = "Cplusplus"; *str1 = 'M'; In C, the above...
9
by: Eric | last post by:
I am working on a large, old code base and attempting to move it to GCC 4.2. Throughout the code, there is stuff like: char *aVar = "aString"; or void aFunc( char *aVar) { ... } aFunc(...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.