Image

Imagexsvenx wrote in Imagecpp 😯confused

Listens: Anam Cara

Function templates inside of a class

First off, hi, I'm new, nice to meet you, blah, blah, blah...

Now, say I have a class foo, and I want to define a function template inside that class, bar, how would I go about doing that? (I hope that made sense, but in case it didn't...)

So, for example say foo is defined as follows:

class foo {
private: ...
public: ...
void bar(float a);
void bar(int a);
void bar(short a);
...
};

In normal circumstances, I could make the function bar a template using

template < class T > //using the spaces, because LJ thinks those are HTML tags...
void bar(T a) {...}

how would I implement that inside of a class?

Any help appreciated, thanks.