473,385 Members | 1,707 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,385 software developers and data experts.

How change the key in the map?

1
I need make it without loop (for, while...).
Only by methods STL.
Loop accecible only for print the results.

Expand|Select|Wrap|Line Numbers
  1. class Obj
  2. {
  3. public:
  4.   string get_str() const;
  5.   int get_int() const;
  6. private:
  7.   Obj( string my_str_, int my_int_ );
  8.   string my_str;
  9.   int my_int;
  10. }
  11.  
Expand|Select|Wrap|Line Numbers
  1. class Map_obj
  2. {
  3. public:
  4.   void insert_obj( string my_str, int my_int );
  5.   void print_ordre_by_str() const;
  6.   void print_ordre_by_int() const;
  7.   void del_by_int( int i );
  8. private:
  9.   map<string, Obj*> my_map;
  10. }
  11.  
For insert_obj() I finished:
Expand|Select|Wrap|Line Numbers
  1. void Map_obj::insert_obj( string my_str, int my_int )
  2. {
  3.     Obj* ptr = new Obj( my_str, my_int );
  4.      my_map.insert( make_pair<string> ( my_str, ptr ) );
  5. }
  6.  
For print_ordre_by_str() i don't need make order.
Because it's order by string by default.
Expand|Select|Wrap|Line Numbers
  1. map <string, Obj*>::const_iterator ptr = my_map.begin();
  2. while ( ptr != my_map.end() )
  3. {
  4.     cout << *ptr->second << endl;
  5.     ptr++;
  6. }
  7.  
But i don't know how realise:
print_ordre_by_int() //print the Obj in order by int
and
del_by_int( int i ) //delete the Obj with searched int
Nov 20 '06 #1
0 1167

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: J.C. Flores | last post by:
Hello all, First of all, I must state that I'm new to SQL Server, but have been a long-time software guy for quite some time. Please excuse the potential simplicity of the solution to my...
1
by: Spike | last post by:
Hello! Im going to make a javascript for changing alot of images. But im not sure how to do it., where to start.. Ok, first.. this is the isue. I have 3 images(I call them 1a-3a). when u...
0
by: beanweed | last post by:
BACKGROUND ---------- I have an ASP.NET application having two panels. In one panel, an XML document, transformed using xsl, is displayed. In the other panel are some controls that allow a user...
5
by: Hank | last post by:
My Access 2000 code has been running for several years in our main plant. Now we need to install it, as a stand-along application, at remote sites, some of which are out of state. My problem is...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
4
by: active | last post by:
It appears to me that if I change the Control's client size the controls size does not change to agree with the new size. Does it work like the VB6 ScaleWidth and ScaleHeight? That is after I...
3
by: Tom | last post by:
I am writing a Visual basic .Net database application. There are many forms that first let you select and look at a DB record and then when you click a "modify" button you are allowed to change...
2
by: J | last post by:
Hello. I apologize if this isn't the appropriate group for this question but I was wondering if it's possible to allow regular windows domain users to change their passwords through an .asp page? ...
11
by: Simon | last post by:
Dear reader, The syntax for the VBA code to change the RowSource of a Master Report is: Me.RowSource = "TableOrQueryName"
1
by: monkey1001 | last post by:
my program is suppose to show my due change and i got it working but my change and coins are wrong how can i improve it thank you..(its supposed to be in java)
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.