Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22075

C++ function`s declaration and definition are different but it works well

$
0
0

I'm writing some C++ code
And I found a very strange thing
Like below code, it works well even though a function's declaration and definition are different

Does anyone know how can this is possible?
build cmd : g++ main.cpp foo.cpp

// main.cpp
#include <iostream>

char foo();

int main() {
    foo();
}

// foo.cpp
#include <iostream>

void foo() {
    std::cout << "I'm foo"<< std::endl;
}

Viewing all articles
Browse latest Browse all 22075

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>