Created
April 29, 2012 19:07
-
-
Save rchl/2552756 to your computer and use it in GitHub Desktop.
template
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 <stdio.h> | |
extern void print1(); | |
extern void print2(); | |
int main() | |
{ | |
printf("Two values printed below should be different?\n"); | |
print1(); | |
print2(); | |
return 0; | |
} |
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 <stdio.h> | |
template<typename T> | |
class SuperFoo | |
{ | |
public: | |
void print_value(T& arg) | |
{ | |
printf("Got value: %d\n", arg.value); | |
} | |
}; |
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 <stdio.h> | |
#include "tmpl.h" | |
typedef union TYPE | |
{ | |
unsigned short value; | |
unsigned int integer; | |
} TYPE; | |
void print1() | |
{ | |
TYPE t; | |
t.integer = -1; | |
SuperFoo<TYPE> impl; | |
impl.print_value(t); | |
} |
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 <stdio.h> | |
#include "tmpl.h" | |
typedef union TYPE | |
{ | |
unsigned int value; | |
} TYPE; | |
void print2() | |
{ | |
TYPE t; | |
t.value = -1; | |
SuperFoo<TYPE> impl; | |
impl.print_value(t); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment