Created
February 21, 2018 05:06
-
-
Save 2bbb/a61a76ba3c441b8b3b3e5cc3ba49b71f to your computer and use it in GitHub Desktop.
duplicate
This file contains 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
#!/bin/bash | |
clang++ -Wall impl.cpp sub.cpp -o impl.a -std=c++11 | |
./impl.a |
This file contains 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 | |
#include <iostream> | |
static int &P(int x = int()) { static int _{x}; return _; } | |
static int &p{P(8)}; | |
struct Q { | |
static int &q(int x = int()) { static int _{x}; return _; } | |
}; | |
static int &q{Q::q(8)}; | |
static const int T{24}; |
This file contains 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 "sub.h" | |
void print_p() { | |
std::cout << "impl ++p: " << ++p << std::endl; | |
} | |
void print_q() { | |
std::cout << "impl ++q: " << ++q << std::endl; | |
} | |
int main(int argc, char *argv[]) { | |
sub_print_p(); | |
print_p(); | |
std::cout << std::endl; | |
sub_print_q(); | |
print_q(); | |
} |
This file contains 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
void sub_print_p() { | |
std::cout << "sub ++p: " << ++p << std::endl; | |
} | |
void sub_print_q() { | |
std::cout << "sub ++q: " << ++q << std::endl; | |
} |
This file contains 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 | |
#include "header_only.h" | |
void sub_print_p(); | |
void sub_print_q(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment