Skip to content

Instantly share code, notes, and snippets.

@threez
Created June 30, 2011 19:52
Show Gist options
  • Save threez/1057058 to your computer and use it in GitHub Desktop.
Save threez/1057058 to your computer and use it in GitHub Desktop.
A simple example to show cpp to my friends ;-)
#include <iostream>
template <typename MsgType>
class Greeting {
private:
MsgType m_pre;
MsgType m_post;
public:
Greeting(MsgType pre)
: m_pre(pre) {}
Greeting(MsgType pre, MsgType post)
: m_pre(pre), m_post(post) {}
void hello(MsgType name) {
std::cout << m_pre << name;
if(m_post != NULL) std::cout << m_post;
std::cout << std::endl;
}
};
int main(int argc, char* argv[]) {
Greeting<const char*> foo("Hallo ");
foo.hello("Ruben");
Greeting<const char*> bar("Hey", ", was geht ab?");
bar.hello("Vincent");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment