BUG: ClassView Cannot Add Member Functions To Template Classes

ID: Q192629


The information in this article applies to:


SYMPTOMS

The following error occurs when trying to add member functions to template classes using ClassView:

Unable to create the implementation of this function


RESOLUTION

To add member functions to a template class, you must manually enter the functions into the source files.


STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

Steps to Reproduce Behavior

  1. Create a default MFC AppWizard (exe).


  2. Add a generic class to the project:

    1. Select the project in ClassView.


    2. Right-click the mouse and select New Class.


    3. Select Generic from the Class Type combo box.


    4. Give the class a name, such as CMyGenericClass, and click OK.




  3. Edit this generic class declaration, constructor definition, and destructor definition by adding the template keyword along with the type list, for example:
    
          //generic class declaration:
    
          template <class c> class CMyGenericClass {
          public:
             CMyGenericClass();
             virtual ~CMyGenericClass();
          };
    
          //constructor and destructor definitions:
    
          template <class c> CMyGenericClass<c>::CMyGenericClass()
          {
          }
    
          template <class c> CMyGenericClass<c>::~CMyGenericClass()
          {
          } 


  4. In ClassView, right-click CMyGenericClass and select "Add Member Function."


  5. Enter the function name and return type. Click OK. A dialog box is displayed indicating the following error:
    Unable to create the implementation of this function


In Visual C++ 6.0, you do not have the ability to jump to a template function declaration from ClassView unless the template function is defined inside the class declaration (inline).

For additional information, please see the following article in the Microsoft Knowledge Base:
Q154112 ClassView Cannot Find Template Member Function Definition

Additional query words: kbDSupport


Keywords          : kbClassView kbide kbVC500 kbVC500bug kbVC600 kbVC600bug kbGrpDSTools 
Version           : WINNT:5.0,6.0
Platform          : winnt 
Issue type        : kbbug 

Last Reviewed: August 8, 1999