I create a C++ project test
that contains three files as follows:
hello.hpp:
#ifndef HELLO_H
#define HELLO_H
int cHelloSay();
#endif
hello.cpp:
#include "hello.hpp"
#include<iostream>
int sayHello(){
std::cout << "123";
}
int i=sayHello();
and main.cpp:
#include "hello.hpp"
int main(int argc, char** argv) {
return 0;
}
then I compile this project and it outputs:123
. So I am confused why the line int i=sayHello();
is executed though main()
does not call it ?