I am trying to initialize a very large number and then pass it to a function:
1 2 3
int iteration = 2000000000;
void function(iteration);
My program throws an exception when the function is called. Is this because I need to use a different integer type since the number is so big? I have tried using long, long long, double and long double to initialize 'iteration' and I keep getting exceptions. Any ideas???? Thanks in advance...
Ok I think I found the problem. In my function where I am getting an exception thrown I am using vector::reserve and allocating memory for the vector 'stack'. The amount of bins I am allocating is based on 'iteration':
It seems whenever I am using a large enough number to allocate memory for the stack vector I get an exception. I think this because the problem goes away when I use a smaller number for 'iteration' like for example 2000000. How can I make vector::reserve work when allocating large numbers????????
How in the hell does your code compile? Your secondary class is missing the terminating semicolon, and also why is it a class instead of a struct (either works, but common practice, or something, dictates the use of a struct for variables and no functions)
But as for your problem, depending on the IDE you're using, as long as the number doesn't overreach the limitations of an int (2.1 billion for signed, 4.2 billion for unsigned) you shouldn't be having an issue. And actually, I can't recall the IDE giving a damn either. what's it throwing?