Where to put typedef std::map<key,val>....

T

tomix

Hi,
I have a domain model written with STL and a client which uses it
I would like to give the client a better way to declare a container.
Where is the best place to put all my typedefs?
(typedef list <EnrollInfo> EnrollInfoList)

Thanks in advance.
 
M

mlimber

tomix said:
I have a domain model written with STL and a client which uses it
I would like to give the client a better way to declare a container.
Where is the best place to put all my typedefs?
(typedef list <EnrollInfo> EnrollInfoList)

We have no idea. You'll have to give us more specific information about
how the code is laid out. Generally, you'll want to put types,
constants, and variables at the smallest (i.e., most nested) scope you
can.

Cheers! --M
 
T

tomix

Assuming I have a domain model with students ,lecturers ,courses and
,course offers

And most of classes have a method which return list<EnrollInfo*>&,
In the client many function uses those methods.

Defining the type in the domain model seems to me the way to go
Maybe i just can encapsulate them in a namespace? or just put them in a
header file?


Thanks in advance.
 
M

mlimber

Please don't top-post (see
Assuming I have a domain model with students ,lecturers ,courses and
,course offers

And most of classes have a method which return list<EnrollInfo*>&,
In the client many function uses those methods.

I would suggest:

const list< some_smart_ptr<EnrollInfo> >& instead.

If it's not const here, why hide it behind member functions in the
object that owns it? Using a smart pointer (e.g., std::tr1::shared_ptr
aka boost::shared_ptr) here makes your list exception-safe and provides
automatic cleanup while still allowing for polymorphic usage.
Defining the type in the domain model seems to me the way to go
Maybe i just can encapsulate them in a namespace? or just put them in a
header file?

Show us more code (see the guidelines on posting code here:
<http://parashift.com/c++-faq-lite/how-to-post.html#faq-5.8>).

Cheers! --M
 

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

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top