This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int bar(); | |
int foo(){ | |
return bar(); | |
} | |
int bar(){ | |
return 1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -c example.cpp -o example.o |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ -c main.cpp -o main.o | |
g++ -c util.cpp -o util.o | |
g++ main.o util.o -o a.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int foo(); | |
int foo(); | |
int foo(){ | |
return 1; | |
} | |
int main(){ | |
return foo(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
one_definition_rule# g++ -c error1.cpp | |
error1.cpp: In function ‘int foo()’: | |
error1.cpp:5:5: error: redefinition of ‘int foo()’ | |
int foo(){ | |
^~~ | |
error1.cpp:1:5: note: ‘int foo()’ previously defined here | |
int foo() { | |
^~~ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
muti_file# g++ -c main.cpp | |
muti_file# g++ -c main.cpp -o main.o | |
muti_file# g++ -c util.cpp -o util.o | |
muti_file# g++ main.o util.o -o a.out | |
util.o: In function `foo()': | |
util.cpp:(.text+0x0): multiple definition of `foo()' | |
main.o:main.cpp:(.text+0x0): first defined here | |
collect2: error: ld returned 1 exit status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int foo(); | |
int main(){ | |
return foo(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
no_header_file# g++ -c main.cpp -o main.o | |
no_header_file# g++ -c util.cpp -o util.o | |
no_header_file# g++ main.o util.o -o a.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "util.h" | |
int main(){ | |
return foo(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Time { | |
int hour; | |
int minute; | |
Time(int h, int m) : hour(h), minute(m){} | |
}; | |
bool isDayTime(Time t); |