Skip to content

Commit

Permalink
Add Answer for ex_16_49
Browse files Browse the repository at this point in the history
  • Loading branch information
zhqu1148980644 authored Mar 20, 2019
1 parent 9861167 commit b5aa023
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ch16/ex16_49_overload_template.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#include <iostream>
using std::cout;
using std::endl;

template <typename T> void f(T)
{
cout << "template 1\n";
}

template <typename T> void f(const T *)
{
cout << "template 2\n";
}

template <typename T> void g(T)
{
cout << "template 3\n";
}

template <typename T> void g(T*)
{
cout << "template 4\n";
}


int main()
{
int i = 42, *p = &i;
const int ci = 0, *p2 = &ci;
g(42);
g(p);
g(ci);
g(p2);
f(42);
f(p);
f(ci);
f(p2);
}

0 comments on commit b5aa023

Please sign in to comment.