why get these error?
"undefined reference to `Main(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, bool)'"
these error don't make sence to me.. can anyone explain?
instead create another topic, because the next question is about these code, i must ask here.. sorry.
like you see, the Main() have 2 arguments... can i create another function: void Main()
for call it, if is defined?
Yes, you can overload functions with different argument lists. So, go ahead and define void Main().
However, you might want to reconsider naming any function void Main(). It is too similar to int main() that it might confuse the reader. I would recommend you change the name of Main() to something easier to identify.
my problem is: if i define the Main() without parameters, that 'if' will give me some errors because the Main() with arguments isn't defined.
i need to have 2 Main() functions(1 with arguments and other without).
my problem is that i can't test\call undefined functions.
the original main() function can have arguments or not... can i do functions like these?
error message:
"undefined reference to `Main(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, bool)'"
like the error that i had before.
maybe the best question would be: the original main() can have arguments or don't. how can i do that?
You have default arguments for both arguments, so it's ambiguous which function you're referring to.
get rid of the = {0} part of the first Main prototype.
What you currently have is equivalent to me saying:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void func(int x = 3, int y = 4)
{
}
void func()
{
}
int main()
{
func(); // Error: which function should be called here? Both are equally valid due to default parameters.
}
What you can't do is have default values for every argument in the version that has arguments. Because if you do that, the compiler has no way of knowing which version you're trying to call when you do:
Main();
EDIT: Here's a question for you:
If you're happy to have defaults for all the arguments to Main(foo, bar), then why do you also need a second Main() ? What so you want that second function to do, that would be different from calling the first function using all default arguments?