質問

Conceptual question. Consider the following code:

#include<stdio.h>

int brasa(int, float); 
int brasa(int, int); 
float brasa(int, int);

int main(){

return 0;
}

The compiler gives the following errors:

Line 4: error: conflicting types for 'brasa'
Line 3: note: previous declaration of 'brasa' was here
Line 5: error: conflicting types for 'brasa'
Line 3: note: previous declaration of 'brasa' was here

Which kind of message is that? Another conceptual question: do the three declarations all declare the same function?

役に立ちましたか?

解決

In C you can't declare a variable/function multiple times with different types (incompatible types). There is no function overloading, unlike in C++, in C.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top