Question

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?

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top