B
Brad Moore
Hey all,
I'm getting the following compiler error from my code. I was wondering
if anyone could help me understand the concept behind it (I actually did
try and compile this degenerate example).
int foo(const char* argv[]) { return 0; }
int main(int argc, char* argv[])
{
foo(argv);
return 0;
}
Error: cannot convert parameter 1 from char** to const char**
I tried using an explicit type cast, and it worked. However, I'd like
to know the difference between the above code and the following (which
did compile):
int goo(const int x) { return 0; }
int main(int argc, char* argv[])
{
int x;
goo(x);
}
I've been reading that using const in your args list is a useful way of
noting that an argument isn't changed. If foo(const char* argv[]) is
bad form in some way, please let me know.
To reiterate, I did get the above code to work. I was just wondering
what the good programming practice is (and the concept behind it).
Thanks for your expertise and time,
-Brad
I'm getting the following compiler error from my code. I was wondering
if anyone could help me understand the concept behind it (I actually did
try and compile this degenerate example).
int foo(const char* argv[]) { return 0; }
int main(int argc, char* argv[])
{
foo(argv);
return 0;
}
Error: cannot convert parameter 1 from char** to const char**
I tried using an explicit type cast, and it worked. However, I'd like
to know the difference between the above code and the following (which
did compile):
int goo(const int x) { return 0; }
int main(int argc, char* argv[])
{
int x;
goo(x);
}
I've been reading that using const in your args list is a useful way of
noting that an argument isn't changed. If foo(const char* argv[]) is
bad form in some way, please let me know.
To reiterate, I did get the above code to work. I was just wondering
what the good programming practice is (and the concept behind it).
Thanks for your expertise and time,
-Brad