Template member operators.

A

Alan Woodland

Is the following construct legal? If yes how does one actually call the
operator? I've tried quite a few variations on way of calling this, all
to no avail.

class Foo {
public:
template <typename T> const T& operator*() const
};

Thanks,
Alan
 
A

Alan Woodland

Appologies:

Alan Woodland wrote:
This line:
template <typename T> const T& operator*() const
Should read as:

template <typename T> const T& operator*() const;

Alan
 
K

Kai-Uwe Bux

Alan said:
Is the following construct legal? If yes how does one actually call the
operator? I've tried quite a few variations on way of calling this, all
to no avail.

class Foo {
public:
template <typename T> const T& operator*() const
};

class Foo {
public:
template <typename T> const T& operator*() const
{}
};

int main ( void ) {
Foo f;
f.operator*<int>();
}


Best

Kai-Uwe Bux
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top