Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) TemplateClassExample1

 

STLQt CreatorWindows

 

Template class example 1: class holding a templated member variable is a template class example.

 

Technical facts

 

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./CppTemplateClassExample1/CppTemplateClassExample1.pro

 

include(../../ConsoleApplication.pri)
SOURCES += main.cpp

 

 

 

 

 

./CppTemplateClassExample1/main.cpp

 

#include <iostream>

template <class T>
struct MyClass
{
  T x;
};

int main()
{
  MyClass<int> m;
  m.x = 10;
  std::cout << m.x << std::endl;
}

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml