"instantiated from here" compile error when using template

Discussion in 'C++' started by yinglcs@gmail.com, Feb 18, 2006.

  1. Guest

    I have the following code, which use template as the parent class of my
    other class.

    But I have "instantiated from here" compile error at this line:
    class C: public B2<A>.

    Can some one please tell me why?

    class AI {

    public:
    ~AI() {};
    virtual void print(int i) = 0;

    };
    class A {
    private:
    A(const A& aimpl) {};

    public:
    int i;
    void print(int i) { cout << "hello world " << endl; }
    A(): i(9){};
    };
    template<class T>
    class B2: public AI {

    public:
    ~B2() {};
    virtual void print(int i) { cout << i<< endl; };
    };

    class C: public B2<A> { // "instantiated from here" compile error
    this line

    };

    int main(int argc, char **argv) {

    C c;
    c.print(1);


    }
    , Feb 18, 2006
    #1
    1. Advertising

  2. Pete Becker Guest

    wrote:
    > I have the following code, which use template as the parent class of my
    > other class.
    >
    > But I have "instantiated from here" compile error at this line:
    > class C: public B2<A>.
    >
    > Can some one please tell me why?
    >


    This message is a helper for one that came earlier. The earlier one told
    you what the error was, and where it occurred. This one points you to
    the location where the template with the error was being instantiated.

    --

    Pete Becker
    Roundhouse Consulting, Ltd.
    Pete Becker, Feb 18, 2006
    #2
    1. Advertising

  3. Luke Meyers Guest

    Pete Becker wrote:
    > wrote:
    > > I have the following code, which use template as the parent class of my
    > > other class.
    > >
    > > But I have "instantiated from here" compile error at this line:
    > > class C: public B2<A>.
    > >
    > > Can some one please tell me why?
    > >

    >
    > This message is a helper for one that came earlier. The earlier one told
    > you what the error was, and where it occurred. This one points you to
    > the location where the template with the error was being instantiated.


    That's compiler-dependent. In my experience, it is a helper for the
    message which follows, not the prior.

    Luke
    Luke Meyers, Feb 19, 2006
    #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. Fernando Cuenca
    Replies:
    4
    Views:
    2,513
    Gianni Mariani
    Sep 6, 2004
  2. Replies:
    1
    Views:
    1,041
    Rolf Magnus
    Feb 13, 2006
  3. Replies:
    2
    Views:
    1,084
    Daniel T.
    Feb 13, 2006
  4. Nagaraj
    Replies:
    1
    Views:
    838
    Lionel B
    Mar 1, 2007
  5. Jeff
    Replies:
    3
    Views:
    508
Loading...

Share This Page