stl: what member function need to exist in class for list implementation

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

    stl: what member function need to exist in class for list implementation

    for a class such as:

    class A
    {
    public:
    A();
    ///// leave everything missing for purpose of example

    public: /// member vars

    wchar* szString; // set to NULL
    someobj* pObj; // set to NULL on default constructor
    };

    what would the minimum member functions you would want to implement for
    a list such as?:

    std::list<A> A_List;

    I would expect: =, A(const A&), A() and ~A().

    I hope this question is plain enough.

  • Bob Hairgrove

    #2
    Re: stl: what member function need to exist in class for list implementation

    On 13 Jan 2006 15:34:32 -0800, "gerg" <jacklig@gmail. com> wrote:
    [color=blue]
    >for a class such as:
    >
    >class A
    >{
    >public:
    > A();
    >///// leave everything missing for purpose of example
    >
    >public: /// member vars
    >
    >wchar* szString; // set to NULL
    >someobj* pObj; // set to NULL on default constructor
    >};
    >
    >what would the minimum member functions you would want to implement for
    >a list such as?:
    >
    >std::list<A> A_List;
    >
    >I would expect: =, A(const A&), A() and ~A().[/color]

    As a bare minimum, yes. But it's not enough if you want to initialize
    the pointer members in the constructor as well, e.g. when you call
    list<A>::push_b ack(A(...)).

    --
    Bob Hairgrove
    NoSpamPlease@Ho me.com

    Comment

    Working...