Created
July 19, 2018 20:05
-
-
Save TheNerdyHamster/622324ace38e08b8a2b6810cd9c235ae to your computer and use it in GitHub Desktop.
Special Templates
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> | |
using namespace std; | |
template <class T> | |
class noChar{ | |
public: | |
noChar(T x){ | |
cout << x << " is not a character!" << endl; | |
} | |
}; | |
template <> | |
class noChar<char>{ | |
public: | |
noChar(char x){ | |
cout << x << " is indeed a character!" << endl; | |
} | |
}; | |
int main() { | |
noChar <int> nObj(45); | |
noChar noChar1('d'); | |
noChar <char> noChar2('d'); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment