Skip to content

Instantly share code, notes, and snippets.

@jitpaul

jitpaul/Intro2 Secret

Created May 4, 2018 06:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpaul/5754d02d63437de25e01410784951bbc to your computer and use it in GitHub Desktop.
Save jitpaul/5754d02d63437de25e01410784951bbc to your computer and use it in GitHub Desktop.
Templates
#include <iostream>
using namespace std;
template <int min, int max>
class ExampleClass {
};
int main() {
/*Incorrect usage of non-type parameters. They should be known at compile time.*/
int min1, max1;
cin >> min1; cin >> max1;
ExampleClass<min1, max1> ec1;
/*Correct Usage non-type parameters.*/
ExampleClass<0, 10> ec2;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment