trying to learn class templates what am i doing wrong

This is a discussion on trying to learn class templates what am i doing wrong within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream> #include <fstream> #include <string> #include <iomanip> using namespace std; const int CAPACITY = 5; template <class T> ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    14

    trying to learn class templates what am i doing wrong

    Code:
    #include <iostream>
    #include <fstream>
    #include <string>
    #include <iomanip>
    
    
    using namespace std;
    const int CAPACITY = 5;
    
    template <class T>
    
    class A
    {
            public:
                      A();  
                    ~A();  
        
            private:
            T num;
            
    };
    
    template<class T>
    
     A<T>::A()
    
    {
    
        cout << "Constructor started"<<endl;
    
    }
    
    int main(){
    
        A<int> object;
        system("pause");
    }
    just want to start the constructor but i get an error message
    Error 2 error LNK1120: 1 unresolved externals

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    6,245
    The unresolved external will be because you have not defined the destructor.
    Right 98% of the time, and don't care about the other 3%.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me learn what im doing wrong
    By Die The Villain in forum C Programming
    Replies: 6
    Last Post: 04-08-2011, 11:01 PM
  2. Class templates
    By SterlingM in forum C++ Programming
    Replies: 1
    Last Post: 01-09-2010, 08:11 PM
  3. New to class templates
    By lisa1901 in forum C++ Programming
    Replies: 10
    Last Post: 10-02-2007, 04:23 PM
  4. class templates...
    By Anddos in forum C++ Programming
    Replies: 1
    Last Post: 03-17-2006, 08:30 PM
  5. class templates
    By tygernoot in forum C++ Programming
    Replies: 2
    Last Post: 11-21-2004, 09:26 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21