I tried in my own code to create definition of something, but the compiler couldn't recognize it, so just simply the code, I made a more short-abstract code that will represent what I'm trying to do:
template <class T>
class A
{
public:
A() {}
~A() {}
class B
{
T x;
public:
B() : x(0) {}
~B(){}
void printAB() const;
B& increase();
};
};
Now, I want to make a definiton of printAB
and increase
outside the class, so printAB
doesn't make any problem because it returns void, but when I'm trying to make definiton of PrintAB
the compiler doesn't recognize it and make red underline under it:
This one works good:
template <class T>
void A<T>::B::printAB() const
{
cout << "Hello World" << endl;
}
And this one it doesn't recognize:
template<class T>
A::B & A<T>::B::increase()
{
x++;
return *this;
}
I also tried to make this declaration:
template<class T>
A<T>::B & A<T>::B::increase() {
...
}
I must say that it doesn't work with A as you guys suggested, so please any other solution that may help?