473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 2613
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: David | last post by:
Hello, I try to store PROLOG_TERMs in a map which is again stored in another map, to realise this I am using a composite key of two strings. The class compiles fine, but when I insert an element,...
1
by: gipsy boy | last post by:
// -- using namespace std; map<string,string> formMap; list<string> formParams; for(list<string>::iterator fit = formParams.begin(); fit!=formParams.end(); fit++) { cout << "key=" << *fit;...
5
by: Peter Jansson | last post by:
Hello, I have the following code: std::map<int,std::set<std::string> > k; k="1234567890"; k="2345678901"; //... std::set<std::string> myMethod(std::map<int,std::set<std::string> > k)...
13
by: jstanforth | last post by:
This is probably a very obvious question, but I'm not clear on what operators need to be implemented for std::map.find() to work. For example, I have a class MyString that wraps std::string, and...
19
by: Erik Wikström | last post by:
First of all, forgive me if this is the wrong place to ask this question, if it's a stupid question (it's my second week with C++), or if this is answered some place else (I've searched but not...
4
by: lada77 | last post by:
All, Just wondering if one of you very helpful guru's out there could comment on some odd behaviour I am seeing. I'm betting it is something obvious but I am not experienced enough to tell...
3
by: newbie | last post by:
Same thing g++ complains when using hash_map<>, but is happy with map<--I understand hahs_map is not standardized, but since the compiler didn't complain something like 'hash_map<not defined', I...
9
by: subramanian100in | last post by:
Consider the program x.cpp : #include <cstdlib> #include <iostream> #include <list> #include <map> using namespace std; int main()
6
by: Juha Nieminen | last post by:
joseph cook wrote: Not always. By default, yes, but you can specify other comparators, eg: std::map<int, int, std::greaterreversedMap;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.