Hi everyone,
I used STL map in my code and I am wondering is the associate data automatically initialized or not. The reason I am asking is that I have two arrays of data, and the first array is index, and second array is my data corresponding to the index. But there are duplicate indexs and I want to add up the data of duplicate index.
For example;
map<int index, double data> mid;
mid[index] += data;
So I want to know at beginning, is the data are initialized to 0. or I have to do it myself? Thanks in advance.
Jingbin
2 1480 gpraghuram 1,275
Recognized Expert Top Contributor
Hi everyone,
I used STL map in my code and I am wondering is the associate data automatically initialized or not. The reason I am asking is that I have two arrays of data, and the first array is index, and second array is my data corresponding to the index. But there are duplicate indexs and I want to add up the data of duplicate index.
For example;
map<int index, double data> mid;
mid[index] += data;
So I want to know at beginning, is the data are initialized to 0. or I have to do it myself? Thanks in advance.
Jingbin
mpas dosent allow duplicate indexes, only multi-map allow duplicate index.
Raghu
The map in your case will be initialized to 0.00 . However it is not the case with types such as strings or user classes. which tend to by null(0). So you should be careful.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: knutsample |
last post by:
Hello!
I'm trying to associate a file extension to my wxPython script so that
all I have to do is double click on the file and my python script will
load up with the path of that file.
For instance, I've associated all .py files to be opened up with
emacs.exe. If I double click on a .py file, emacs.exe would open up
with that file in its buffer.
|
by: John Baker |
last post by:
Hi:
I have used this group a number of times simply because while the manuals for Access may
show the technology, but most are really weak on how to apply it in special situations and
the indexes are less that complete!. This is also the first real application iI have
developed for Access, although I have done a number in Lotus Approach.
I have a table with information on how an Associate is to be handled under a specific
Purchase...
|
by: Dailan |
last post by:
Hi,
I create a tree view. Each node has link button associate with it, which includes add, edit, delete buttons. The way I did is for users who have very low capablity of using computer. Now I encoutered problem. At certain situation the event does not fire when I click my link button.
I generate my tree and link button on fly, and associate event with button. Tree is in my top panel. Detail information of each node is in my bottom panel....
|
by: bryan |
last post by:
I'm using the UIP App block and I have overridden the Initialize
method, but my override never gets called. Here's the code:
public override void Initialize(TaskArgumentsHolder args,
ViewSettings settings) {
base.Initialize (args, settings);
Logger.Write("Initialize");
|
by: Niclas |
last post by:
Hi,
in ASP .Net, I can associate a value with and item in a dropdown list, for
example when binding to a list of employees, I can store the employeeid as a
value associated with each name in in the list so I can use this later when
retrieving data from my database.
I am now trying to develop a Windows forms app (.Net 2.0) and can find how
to do this when using a combobox set to the dropdownlist style (assume this
is the control I...
| |
by: toton |
last post by:
Hi,
In C++ when I initialize an array it, also initializes the class that
it contains, which calls the default constructor. However, I want to
initialize the array only (i.e reserve the space) and use my specific
constructor to initialize the class. How to do it without using malloc?
Something like Point* pt = new Point; I want it to reserve the
space for N points only, and not to call default constructor. I dont
have a default...
|
by: Ryan Liu |
last post by:
Hi,
As I remember theare are In and Out stream associate with a socket.
TcpClient seems there in only one NetworkStream to do both read and write.
Then will it be a conflicit if both side try to send data?
And when one end is sending data, if another end is not calling Recevive or
BeginReceive, will the sender be blocked? Or recevier side network hardware
will read anyway, just our high-end application has not take the data yet?
|
by: BD |
last post by:
Hi all.
Running SQL2K SP4 on W2K3 Standard, SP4.
I have just refreshed a database on one server with a backup from
another. The database had existed previously on the target server, and
I am just refreshing its contents. I used the following approach
1) From the target server, create a SQL script with users and roles
2) From the source server, back up the db
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |