Advertisement
Guest User

Test Class C++ template

a guest
Aug 19th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. template<typename X>
  4. class Test {
  5. private:
  6.     X x;
  7.  
  8. public:
  9.     Test (X x) : x(x) {}
  10.  
  11.     void f () {
  12.         std::cout << x << std::endl;
  13.     }
  14. };
  15.  
  16. int main () {
  17.     Test testA(5);               // 17| error: missing template arguments before ‘test’
  18.  
  19.     Test* testB = new Test(5);   // 19 | error: missing template arguments before ‘*’ token
  20.                                  // 19 | error: ‘testB’ was not declared in this scope
  21.                                  // 19 |error: expected type-specifier before ‘Test’
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement