943,895 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 650
  • C++ RSS
Jun 15th, 2009
0

Program crashes question

Expand Post »
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, 24 views)
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ippomarley is offline Offline
10 posts
since Apr 2009
Jun 15th, 2009
0

Re: Program crashes question

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!
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Jun 15th, 2009
0

Re: Program crashes question

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
C++ Syntax (Toggle Plain Text)
  1. flights.~vector();
?
Reputation Points: 395
Solved Threads: 71
Posting Whiz
jencas is offline Offline
362 posts
since Dec 2007
Jun 15th, 2009
0

Re: Program crashes question

Click to Expand / Collapse  Quote originally posted by ArkM ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ippomarley is offline Offline
10 posts
since Apr 2009
Jun 15th, 2009
0

Re: Program crashes question

Click to Expand / Collapse  Quote originally posted by jencas ...
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
C++ Syntax (Toggle Plain Text)
  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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ippomarley is offline Offline
10 posts
since Apr 2009
Jun 15th, 2009
0

Re: Program crashes question

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
C++ Syntax (Toggle Plain Text)
  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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,953 posts
since Aug 2005
Jun 15th, 2009
0

Re: Program crashes question

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
C++ Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ippomarley is offline Offline
10 posts
since Apr 2009
Jun 15th, 2009
0

Re: Program crashes question

The secret is using a great compiler's IDE, such as VC++ 2008 Express, and learning how to debug programs.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is online now Online
21,953 posts
since Aug 2005
Jun 15th, 2009
0

Re: Program crashes question

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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ippomarley is offline Offline
10 posts
since Apr 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: missing type specifier - C++ does not support default-int
Next Thread in C++ Forum Timeline: Problem with ifstream returning fail()





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC