Last active
August 29, 2015 14:23
-
-
Save thiagomg/c444563a5efd275df823 to your computer and use it in GitHub Desktop.
Templates e geração de código
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
class NonTemplated { | |
int value; | |
public: | |
using value_type = int; | |
NonTemplated(int a) : value(a) {} | |
int sum(int a) { return value + a; } | |
}; | |
template <typename T> | |
class Templated { | |
T value; | |
public: | |
using value_type = T; | |
Templated(T a) : value(a) {} | |
T sum(T a) { return value + a; } | |
}; | |
//..... | |
NonTemplated nt{1}; | |
Templated<int> ti{1}; | |
Templated<double> td{1.0}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment