class as template parm

Discussion in 'C++' started by Chris Forone, Jun 10, 2008.

  1. Chris Forone

    Chris Forone Guest

    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)?
    Chris Forone, Jun 10, 2008
    #1
    1. Advertising

  2. Chris Forone

    Chris Forone Guest

    > template<class T> class image {
    > 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...
    Chris Forone, Jun 10, 2008
    #2
    1. Advertising

  3. Chris Forone

    Chris Forone Guest

    Victor Bazarov schrieb:
    > Chris Forone wrote:
    >>> template<class T> class image {
    >>> 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...

    >
    > FAQ 5.8.
    >
    > V


    Sorry, but its to complicated to do all these things. But i think its
    what you suggested. Thanks.
    Chris Forone, Jun 10, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cubes
    Replies:
    2
    Views:
    19,807
    cubes
    Dec 9, 2005
  2. Gene Wirchenko
    Replies:
    22
    Views:
    724
    Jeffrey Schwab
    Dec 19, 2003
  3. christopher diggins
    Replies:
    16
    Views:
    735
    Pete Becker
    May 4, 2005
  4. =?Utf-8?B?cm9kY2hhcg==?=

    pass more than one parm

    =?Utf-8?B?cm9kY2hhcg==?=, Feb 14, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    349
    =?Utf-8?B?cm9kY2hhcg==?=
    Feb 14, 2007
  5. cp2004
    Replies:
    0
    Views:
    1,664
    cp2004
    Oct 21, 2007
Loading...

Share This Page