468,268 Members | 1,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,268 developers. It's quick & easy.

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


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 <EnrollInfoEnrollInfoList)

Thanks in advance.

Nov 6 '06 #1
3 2378
tomix wrote:
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 <EnrollInfoEnrollInfoList)
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

Nov 6 '06 #2

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.



mlimber wrote:
tomix wrote:
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 <EnrollInfoEnrollInfoList)

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
Nov 6 '06 #3
tomix wrote:
mlimber wrote:
tomix wrote:
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 <EnrollInfoEnrollInfoList)
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.
Please don't top-post (see
<http://parashift.com/c++-faq-lite/how-to-post.html#faq-5.4>). I've
fixed it for you here.
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

Nov 6 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by David | last post: by
1 post views Thread by gipsy boy | last post: by
19 posts views Thread by Erik Wikström | last post: by
4 posts views Thread by lada77 | last post: by
9 posts views Thread by subramanian100in | last post: by
6 posts views Thread by Juha Nieminen | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.