473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1272
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Larry Beck | last post by:
Below is a problem I am having with templates. I am trying to use a template to avoid having multiple class methods that differ only in the return type of the pointer. I have tried putting in...
5
by: =?iso-8859-1?q?Erik_Wikstr=F6m?= | last post by:
The following code works: #include <iostream> template<class T> struct Test { T t; template<class T, template<class U = Tclass V> Test<T>& foo(V<T>& f)
4
by: Jim Langston | last post by:
This should illistrate what I am trying to do: template <class T> T SomeFunction( T parm ) { return parm; } template <class T> class SomeClass
1
by: teju | last post by:
I am using the OTL library for database interaction(otl.sourceforge.net) This is the sample code from my application: strm_ << parm.corp_id(); strm_ << parm.prod_id(); write_to_log(("Before...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.