When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
36 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Code please
The problem is that you are declaring MOVIE_SIZE_LIST to be 32, but only have 8 movies defined, so in MovieTicketMaster::Init(), you are trying to access movie_name_list[8], which fails since there are only 8 strings in the array
Also, you're directly dereferencing a null pointer on line 240, though that is after the error above, so you haven't run into that yet
but is that not wat this asks
The problem is that you're looping with the assumption of having enough movies, you should only be looping up to kSize, and setting the rest to empty strings/0 instead of trying to access
can u point out the line please
Movie* p_movie = nullptr;
for(int i = 0; i < MOVIE_LIST_SIZE; i++){
if(p_movie->get_movie_name() == movie)
Weird, for me that's line 238-240
is that not me setting it as a nullptr?
Yes, but look at the last line, without modifying p_movie, you're accessing it; or trying to at least
so should add && p_movie != nullptr
but as the first condition
so p_movie != nullptr && p_movie->get_movie_name() == movie
Then you still get a similar error, since nullptr++ is likely not where the first movie is located, it should be something like p_movie = movie_list, to get the first movie in the list, and loop from there
what if i chnaged it to
Movie* p_movie = movie_list[0];
for(int i = 0; i < MOVIE_LIST_SIZE; i++){
if(p_movie->get_movie_name() == movie)
so are u saying i have 2 for loops one ending at k size, and other going from kzsize to 32, also if so whats the point of making it 32 if i only ever need 8?
Yes
Also, I think it might be better for you to go through the debugging yourself, and try to understand what is going wrong: https://onlinegdb.com/I576rG4lF (An online debugger, not the greatest, but sharable) - That way you can directly interact with your code, and see how it works behind the scenes
Online GDB is online ide with compiler and debugger for C/C++. Code, Compiler, Run, Debug Share code nippets.
sorry if im asking dumb questions im p new
No problem, that's why I'm suggesting the debugger, since these are pretty easy to solve, and it makes more sense as to why if you see the code in action
Or at least that is how it was for me
does this make sense?
Not quite, movie_list[0] gives a Movie, not a Movie *
sorry i meant & movie_list[0]
Just FYI, &movie_list[0] == movie_list for c-style arrays (can save you some typing)
whats the point of index 8-31?
oh thanks
No clue, it's your assignment - likely to add some padding?
Or possibly to see how you solve the issue
he never says
@tight fox Has your question been resolved? If so, type !solved :)
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity