template question again

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • booker

    #1

    template question again

    The following codes can't pass compilation in vc7.1,
    error occured at the possition where Foo is called.

    *************** *************** *************** *************** 8
    template<typena me type>
    class base1
    {
    template<typena me type> class base2;
    private:
    typedef base2<type> base2type;
    public:
    virtual void Foo(base2type*) =0;
    };

    template<typena me type2>
    class base2
    {
    };

    template<typena me type>
    class derive
    :public base1<type>
    ,public base2<type>
    {
    typedef base2<type> base2type;
    virtual void Foo(base2type*) {}
    };

    int main(int argc, char* argv[])
    {
    derive<unsigned > * devptr=new derive<unsigned >;
    base1<unsigned> * baseptr=devobj;
    baseptr->Foo(devptr);
    return 0;
    }


  • booker

    #2
    Re: template question again

    the problem is solved thanks

    "booker" <huangshuhuai@k ingsoft.net> дÈëÓʼþ
    news:uZ6oVAryDH A.3116@tk2msftn gp13.phx.gbl...[color=blue]
    > The following codes can't pass compilation in vc7.1,
    > error occured at the possition where Foo is called.
    >
    > *************** *************** *************** *************** 8
    > template<typena me type>
    > class base1
    > {
    > template<typena me type> class base2;
    > private:
    > typedef base2<type> base2type;
    > public:
    > virtual void Foo(base2type*) =0;
    > };
    >
    > template<typena me type2>
    > class base2
    > {
    > };
    >
    > template<typena me type>
    > class derive
    > :public base1<type>
    > ,public base2<type>
    > {
    > typedef base2<type> base2type;
    > virtual void Foo(base2type*) {}
    > };
    >
    > int main(int argc, char* argv[])
    > {
    > derive<unsigned > * devptr=new derive<unsigned >;
    > base1<unsigned> * baseptr=devobj;
    > baseptr->Foo(devptr);
    > return 0;
    > }
    >
    >[/color]


    Comment

    Working...