Created
July 3, 2018 05:40
-
-
Save SyntaxColoring/ad7f7248919d7a51b10b4dbdc508d4e4 to your computer and use it in GitHub Desktop.
Dangerous Linkage
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> | |
struct S | |
{ | |
int i; | |
int f(int j) // Multiply. | |
{ | |
return i*j; | |
} | |
}; | |
int square(int i) | |
{ | |
S s{i}; | |
return s.f(i); | |
} | |
int times_2(int i); | |
int main() | |
{ | |
std::cout << "square(10) = " << square(10) << std::endl; | |
std::cout << "times_2(10) = " << times_2(10) << 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
struct S | |
{ | |
int i; | |
int f(int j) // Add. | |
{ | |
return i+j; | |
} | |
}; | |
int times_2(int i) | |
{ | |
S s{i}; | |
return s.f(i); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment