class as template parm

C

Chris Forone

hello group,

i have a class as template parm for another class. in ctor of the
parameterized class i use a local instance of class from parm. ctor of
param-class compiles fine, but i cant call members.

error: request for member `Decode' in `image [with T = Targa]', which is
of non-class type `Targa ()(std::istreambuf_iterator<char,
std::char_traits<char> >)

thanks & hand, chris

ps/ot: are you interested in uefa european-championship (em)?
 
C

Chris Forone

template said:
public:
image() {
T t;
t.Decode();
}
};

class Targa {
public:
void Decode() {}
};

int main() {
image<Targa> it;
}
Exactly, but with a parm in ctor for class Targa. Possibly thats the
error because i need the parentheses (T t(const std::string& name);)...
Well, this should work, more or less. But how do you get the error
message with such content. I can only think that you must have
forgotten to use parentheses or used too many of them...

image() {
T t(); // t is a *function*
t.Decode(); // cannot use 't' here!!!
}

So, if you are trying to declare 't' here, drop the parentheses.

i cant because of parm...

thanks a lot...
 

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,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top