Like title says, my program is stopping whenever it hits
system("PAUSE")
in my code. I have strong reason to believe that it is not the
system("PAUSE")
that is causing the crash...based on the fact that when I take
system("PAUSE")
, the program still crashes.
To make things a little more specific, the problem occurs in a situation similar to (but not as simple as) the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
class First_Class
{
public:
int number1;
int number2;
};
class Second_Class
{
public:
vector<First_Class *> first_class_vector;
};
class Third_Class
{
public:
vector<Second_Class *> second_class_vector;
};
//so, there's a class containing a vector containing classes that contain //another vector containing classes that contain two int's
void First_Function(Second_Class *second_class)
{
for (int i=0; i<second_class.size(); i++)
{
second_class.first_class_vector[i]->number1 += 1;
second_class.first_class_vector[i]->number2 += 1;
}
}
void Second_Function(Third_Class *third_class)
{
First_Function(third_class.second_class_vector[0]); //ish..probly wrong //syntax
}
int main()
{
Third_Class third_class;
Second_Class second_class;
First_Class first_class;
first_class.number1 = 0;
first_class.number2 = 0;
second_class.first_class_vector.push_back(&first_class);
third_class.second_class_vector.push_back(&second_class);
Second_Function(&third_class);
return EXIT_SUCCESS;
}
|
If the above code mirrors my program, the above code would crash during First_Function. If you slap a
system("PAUSE")
in First_Function, it will just crash at the
system("PAUSE")
. Is there some common thing that might cause my program to crash at a
system("PAUSE")
(or anywhere during the function, for that matter)? Is it possible that there is a memory overflow or something?
Yes, yes, I know lines like
system("PAUSE")
are no good for portability, but it's just for temporary debugging. Any help would be awesome, I'm almost certain that I will get no further with bug-testing by myself.
EDIT: Since it doesn't seem to be clear: The above program is, as the layman may deduce, NOT my actual program code. It's just an example that illustrates the problem that I'm having.