c++ - 为什么main函数里调用函数不能加类型?
巴扎黑
巴扎黑 2017-04-17 14:46:50
0
4
507

如果加了就会出现
[Warning] parameter names (without types) in function declaration [enabled by default]

巴扎黑
巴扎黑

reply all(4)
迷茫

The compiler interprets your line as a function declaration, so it prompts you: type without parameters (without types)
For example:
int main(int argc, char *argv[] )
{

int main(argc, argv);
return 0;

}
will prompt line 3 [Warning] parameter names (without types) in function declaration [enabled by default]
int main(int argc, char *argv[])
{

int main(int argc, char *argv[]);
return 0;

}
declares no ambiguity and no warning.

小葫芦

There is no need to write the return value type when calling a function, just write the function name and parameters directly

黄舟

I’m also confused, there’s a word limit on answering questions

巴扎黑

Because the call itself does not add a type, adding a type is a declaration.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!