Last active
February 18, 2017 15:17
-
-
Save tell/0996941b9c6ac07d8ac9b29cddad873e to your computer and use it in GitHub Desktop.
A sample of extern
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
### https://raw.github.com/github/gitignore/f2ce448f2ba7a092da05482ceca99209127c0884/c++.gitignore | |
# Prerequisites | |
*.d | |
# Compiled Object files | |
*.slo | |
*.lo | |
*.o | |
*.obj | |
# Precompiled Headers | |
*.gch | |
*.pch | |
# Compiled Dynamic libraries | |
*.so | |
*.dylib | |
*.dll | |
# Fortran module files | |
*.mod | |
*.smod | |
# Compiled Static libraries | |
*.lai | |
*.la | |
*.a | |
*.lib | |
# Executables | |
*.exe | |
*.out | |
*.app | |
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
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 "a.hpp" | |
A::A() : a(0), b(a) {} | |
int A::c = 10; | |
const int &A::d = A::c; | |
int N = 100; |
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
#pragma once | |
struct A { | |
int a; | |
const int &b; | |
static int c; | |
static const int &d; | |
A(); | |
}; |
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 <iostream> | |
#include "a.hpp" | |
extern const int N; | |
using namespace std; | |
int main() { | |
A x; | |
x.a = 1; | |
cout << x.b << endl; | |
cout << x.c << endl; | |
cout << x.d << endl; | |
x.c = 20; | |
cout << x.d << endl; | |
cout << N << endl; | |
} |
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
CC = $(CXX) | |
%.out: | |
$(LINK.o) $^ $(LOADLIBES) $(LDLIBS) -o $@ | |
main.out: b.o a.o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment