Click here to Skip to main content
15,126,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a function if is defined line its working fine, but when I define outside the class I am getting compilation error.
Can anyone help me on this??
Here is my code sinppet....
C++
#include<iostream>
#include<map>
#include<string>
#include<conio.h>
#include<list>
using namespace std;
template<class T>
class Test
{
    map<string,T> mobj;
    public:
           void getData();
           map<string,T> show();
           list<Test> Myshow();

};
template<class T>
Test<T>::Myshow()  //This is giving error
 {
           return 0;
}
template<class T>
void Test<T>::getData()
{
     this->mobj.insert(pair<string,T>("",""));
}

int main()
{
    getch();
    return 0;
}

Regards,
Mahesh
Posted
Updated 7-Oct-10 3:52am
v4

template<class T>
Test<T>::Myshow()  //This is giving error


What's the return type of this function? More to the point where is it?

Cheers,

Ash
   
Your MyShow definition lacks return type, change it to:
C++
template<class T>
list<Test<T> > Test<T>::Myshow()  //This is NOT giving error
 {
           return 0;
}

cheers,
AR
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900