Program crashes question

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Apr 2009
Posts: 10
Reputation: ippomarley is an unknown quantity at this point 
Solved Threads: 0
ippomarley ippomarley is offline Offline
Newbie Poster

Program crashes question

 
0
  #1
Jun 15th, 2009
I have a program which is supposed to find the shortest path between airports and users' flight data to find the shortest path between airports; that is, the airports are the nodes and the flights are the edges.

I've not started to implement the algorithm as yet but I am working on the implementation of the airports and the flights.

Unfortunately, my program crashes when I am testing. I've put in debug statements in the code to find out where and why it's crashing but, unfortunately, I'm having a hard time.

I am going to attach the files if anyone could please tell me where I've gone wrong that would be greatly appreciated. Thanks.
Attached Files
File Type: zip airports.zip (195.9 KB, 9 views)
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 2,001
Reputation: ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of ArkM has much to be proud of 
Solved Threads: 343
ArkM's Avatar
ArkM ArkM is offline Offline
Postaholic

Re: Program crashes question

 
0
  #2
Jun 15th, 2009
Well, your program crashed. It looks like a mere assertion, not a question.
Read This Before Posting: http://www.daniweb.com/forums/thread78223.html.
Never send exe files in attachments!
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 360
Reputation: jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice jencas is just really nice 
Solved Threads: 69
jencas jencas is offline Offline
Posting Whiz

Re: Program crashes question

 
0
  #3
Jun 15th, 2009
After inspecting airports.cpp of your source code I recommend that you read a good C++ book. A std::vector of objects member variable doesn't need any initialization in the ctor and no destruction in the dtor. And what the hell do you want to destroy with
  1. flights.~vector();
?
If you are forced to reinvent the wheel at least try to invent a better one!

Please use code tags - Please mark solved threads as solved
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: ippomarley is an unknown quantity at this point 
Solved Threads: 0
ippomarley ippomarley is offline Offline
Newbie Poster

Re: Program crashes question

 
0
  #4
Jun 15th, 2009
Originally Posted by ArkM View Post
Well, your program crashed. It looks like a mere assertion, not a question.
Read This Before Posting: http://www.daniweb.com/forums/thread78223.html.
Never send exe files in attachments!
sorry my bad didn't realize there was an exe in it, but its not harmful. Sorry again
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: ippomarley is an unknown quantity at this point 
Solved Threads: 0
ippomarley ippomarley is offline Offline
Newbie Poster

Re: Program crashes question

 
0
  #5
Jun 15th, 2009
Originally Posted by jencas View Post
After inspecting airports.cpp of your source code I recommend that you read a good C++ book. A std::vector of objects member variable doesn't need any initialization in the ctor and no destruction in the dtor. And what the hell do you want to destroy with
  1. flights.~vector();
?
thanks for pointing that out for me. Sorry I am very new to C++ programming I usually program in Java. I have read lecture notes and done some tutorials, I thought i was doing the right thing.

May you please help me a little more so i can get this working and understand were i have gone wrong.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Program crashes question

 
0
  #6
Jun 15th, 2009
There is an error in the airport1.txt file on line 90
SYD BNE 07:30 1:00
getline() reads it in as SYD BNE07:30 1:00 -- missing the space between BNE and 07:30. I re-typed the line and the program continued to work from there until the next error, which was at the destructor
  1. AllAirports::~AllAirports() {
  2. airports.~map();
  3. }

You can't explicitly call a c++ class's destructor like that because it will crash your program.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: ippomarley is an unknown quantity at this point 
Solved Threads: 0
ippomarley ippomarley is offline Offline
Newbie Poster

Re: Program crashes question

 
0
  #7
Jun 15th, 2009
Originally Posted by Ancient Dragon View Post
There is an error in the airport1.txt file on line 90
SYD BNE 07:30 1:00
getline() reads it in as SYD BNE07:30 1:00 -- missing the space between BNE and 07:30. I re-typed the line and the program continued to work from there until the next error, which was at the destructor
  1. AllAirports::~AllAirports() {
  2. airports.~map();
  3. }

You can't explicitly call a c++ class's destructor like that because it will crash your program.
WOW, you are pretty good, I hope i can improve and get to that level. Thanks you i will keep trying
Last edited by ippomarley; Jun 15th, 2009 at 8:56 am. Reason: mistake in grammer
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,362
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Program crashes question

 
0
  #8
Jun 15th, 2009
The secret is using a great compiler's IDE, such as VC++ 2008 Express, and learning how to debug programs.
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 10
Reputation: ippomarley is an unknown quantity at this point 
Solved Threads: 0
ippomarley ippomarley is offline Offline
Newbie Poster

Re: Program crashes question

 
0
  #9
Jun 15th, 2009
Originally Posted by Ancient Dragon View Post
The secret is using a great compiler's IDE, such as VC++ 2008 Express, and learning how to debug programs.
That solved all the problems. I am really impressed by you, how long did it take for you to get that good? i think i would have to have studied for years to get insight like that.

What else can i do to improve?

Thank very much i appreciate it.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC