Digital
Learning C++
- Joined
- Jul 15, 2018
- Messages
- 57
- Solutions
- 1
- Reaction score
- 12
So I am learning about C++ templates and I am using them to figure out the sources. Right now I only know how to use them for functions.
This is my template and the example code.
and this is how it works
When applied to the sources what would be the scope of a template if it were not defined inside of a class?
This is my template and the example code.
C++:
#include <iostream>
template<typename T>
void p(std::string s, T t){
std::cout << s << " " << t << std::endl;
};
int main() {
p("this is a float", 1.5);
p("this is an integer", 24);
p("this is a character", 'G');
p("this is a string", "a string");
}
C++:
this is a float 1.5
this is an integer 24
this is a character G
this is a string a string
When applied to the sources what would be the scope of a template if it were not defined inside of a class?