Template standard typedef and forward declaration

Discussion in 'C++' started by shaan, Jul 1, 2012.

  1. shaan

    shaan Guest

    i have written following template program. It works on windows, solaris and linux. It give error in AIX. Does my following program comply with standard ?


    template<class T> class Cursor;
    template<class T>
    class Container
    {

    friend class Cursor<T>;
    public:
    typedef class Cursor<T> MyCursor; //compilation error on AIX
    Container()
    {

    }

    private:

    T _a[20];
    } ;

    template<class T>
    class Cursor
    {

    public:
    Cursor(Container<T> *c):
    _c(c)
    {

    }


    T Get()
    {
    return _c->_a[9];
    }

    private:

    Container<T> *_c;
    };

    int main()
    {

    Container<int> c;
    Cursor<int> r(&c);
    r.Get();


    return 0;
    }
     
    shaan, Jul 1, 2012
    #1
    1. Advertising

  2. On 01.07.12 09.45, shaan wrote:
    > i have written following template program. It works on windows, solaris and linux. It give error in AIX. Does my following program comply with standard ?


    It shouldn'd be too much of work to post the error message, isn't it?


    Marcel
     
    Marcel Müller, Jul 1, 2012
    #2
    1. Advertising

  3. shaan

    shaan Guest

    On Jul 1, 2:06 pm, Marcel Müller <> wrote:
    > On 01.07.12 09.45, shaan wrote:
    >
    > > i have written following template program. It works on windows, solarisand linux. It give error in AIX. Does my following program comply with standard ?

    >
    > It shouldn'd be too much of work to post the error message, isn't it?
    >
    > Marcel


    This implementation works fine on AIX. I had wrongly implemented the
    forward reference in production code. This code could be good example
    for template class forward reference and typedef.
     
    shaan, Jul 2, 2012
    #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. qazmlp
    Replies:
    1
    Views:
    637
    Jonathan Turkanis
    Feb 15, 2004
  2. Jordi Vilar
    Replies:
    5
    Views:
    2,308
    Jonathan Turkanis
    Feb 18, 2004
  3. Plok Plokowitsch

    forward declaration vs. typedef

    Plok Plokowitsch, May 30, 2005, in forum: C++
    Replies:
    2
    Views:
    13,406
    Donovan Rebbechi
    May 30, 2005
  4. Jordi Vilar
    Replies:
    5
    Views:
    18,022
    Jonathan Turkanis
    Feb 18, 2004
  5. Mohammad Omer Nasir
    Replies:
    8
    Views:
    4,305
    Dave Rahardja
    Feb 19, 2007
Loading...

Share This Page