468,247 Members | 1,324 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

class as template parm

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)?
Jun 27 '08 #1
4 1111
Chris Forone wrote:
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.
Lemme see if I can imagine what you're doing...
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)
template<class Tclass image {
public:
image() {
T t;
t.Decode();
}
};

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

int main() {
image<Targait;
}

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.
>
thanks & hand, chris

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

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
template<class Tclass image {
public:
image() {
T t;
t.Decode();
}
};

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

int main() {
image<Targait;
}
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...
Jun 27 '08 #3
Chris Forone wrote:
>template<class Tclass image {
public:
image() {
T t;
t.Decode();
}
};

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

int main() {
image<Targait;
}
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...
FAQ 5.8.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #4
Victor Bazarov schrieb:
Chris Forone wrote:
>>template<class Tclass image {
public:
image() {
T t;
t.Decode();
}
};

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

int main() {
image<Targait;
}
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...

FAQ 5.8.

V
Sorry, but its to complicated to do all these things. But i think its
what you suggested. Thanks.
Jun 27 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.