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

G

gerg

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.
 
B

Bob Hairgrove

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().

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_back(A(...)).
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,481
Members
44,900
Latest member
Nell636132

Latest Threads

Top