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

who'd like to explain the usuage of vecor<pair< , > > ?

It is best to show me some examples.

Thanks a lot.

Nov 19 '06 #1
6 1501


On Nov 19, 4:09 am, "asdf" <likemurs...@gmail.comwrote:
It is best to show me some examples.

Thanks a lot.
#include <iostream>
#include <vector>
using namespace std;

vector<pair<int, int squares;

int main()
{
for (int i = 0;i < 5;++i)
{
squares.push_back(make_pair(i, i*i));
}

for (vector<pair<int, int::const_iterator pos =
squares.begin();pos != squares.end();++pos)
{
cout << pos->first << "^2 = " << pos->second << endl;
}
}

Nov 19 '06 #2
Thanks.

ha**********@gmail.com wrote:
On Nov 19, 4:09 am, "asdf" <likemurs...@gmail.comwrote:
It is best to show me some examples.

Thanks a lot.

#include <iostream>
#include <vector>
using namespace std;

vector<pair<int, int squares;

int main()
{
for (int i = 0;i < 5;++i)
{
squares.push_back(make_pair(i, i*i));
}

for (vector<pair<int, int::const_iterator pos =
squares.begin();pos != squares.end();++pos)
{
cout << pos->first << "^2 = " << pos->second << endl;
}
}
Nov 19 '06 #3

asdf wrote in message...
>It is best to show me some examples.
Thanks a lot.
NOooo problem.

// -------
#include <iostream>
#include <ostream>

int main(){
std::cout << "Hello World" << std::endl;
return 0;
} // main()
// -------

Another example:

// -------
#include <iostream>
#include <ostream>

class Hi{ public:
void Say( std::ostream &out ){
out << "Hello World" << std::endl;
return;
}
};

int main(){
Hi Ima;
Ima.Say( std::cout );
return 0;
} // main()
// -------

Your turn.

--
Bob R
POVrookie
Nov 19 '06 #4
Thanks.

ha**********@gmail.com wrote:
On Nov 19, 4:09 am, "asdf" <likemurs...@gmail.comwrote:
It is best to show me some examples.

Thanks a lot.

#include <iostream>
#include <vector>
using namespace std;

vector<pair<int, int squares;

int main()
{
for (int i = 0;i < 5;++i)
{
squares.push_back(make_pair(i, i*i));
}

for (vector<pair<int, int::const_iterator pos =
squares.begin();pos != squares.end();++pos)
{
cout << pos->first << "^2 = " << pos->second << endl;
}
}
Nov 19 '06 #5
BobR wrote:
asdf wrote in message...
It is best to show me some examples.
Thanks a lot.

NOooo problem.

// -------
#include <iostream>
#include <ostream>

int main(){
std::cout << "Hello World" << std::endl;
return 0;
} // main()
// -------

Another example:

// -------
#include <iostream>
#include <ostream>

class Hi{ public:
void Say( std::ostream &out ){
out << "Hello World" << std::endl;
return;
}
};

int main(){
Hi Ima;
Ima.Say( std::cout );
return 0;
} // main()
// -------

Your turn.

--
Bob R
POVrookie
If that's vector<pair< , then I must be really blind as I can't see
it.

Nov 19 '06 #6

ha**********@gmail.com wrote in message ...
>BobR wrote:
>asdf wrote in message...
>It is best to show me some examples.
Thanks a lot.

NOooo problem.
// -------

If that's vector<pair< , then I must be really blind as I can't see
it.
In the message body (s)he said, "It is best to show me some examples.". So, I
showed some examples! I saw NO question about anything IN the post!

template <class A, class Bclass pair{ public:
A a;
B b;
};

For vector you do.... Oh wait, did you actually mean 'std::vector'? You
should state that!

< you starting to get-it? >
<http://www.parashift.com/c++-faq-lite/how-to-post.html>
--
Bob R
POVrookie
Nov 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

58
by: Jeff_Relf | last post by:
Hi Tom, You showed: << private const string PHONE_LIST = "495.1000__424.1111___(206)564-5555_1.800.325.3333"; static void Main( string args ) { foreach (string phoneNumber in Regex.Split...
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...
39
by: Antoon Pardon | last post by:
I was wondering how people would feel if the cmp function and the __cmp__ method would be a bit more generalised. The problem now is that the cmp protocol has no way to indicate two objects are...
11
by: Squeamizh | last post by:
class my_class { public: my_class() : value(0) { } int& get_value() { return value; } const int& get_value() const { my_class& c = const_cast<my_class&>(*this); return c.get_value(); }
13
by: Mark | last post by:
Dear folks, In Javascript, is it possible to get all id names within, say, a <div></divpair? Like the array of "document.images", I mean. The reason I ask, is that I have a calender whose...
44
by: Zytan | last post by:
The docs for List say "The List class is the generic equivalent of the ArrayList class." Since List<is strongly typed, and ArrayList has no type (is that called weakly typed?), I would assume...
2
by: subramanian100in | last post by:
Consider the following piece of code: #include <iostream> #include <fstream> #include <vector> #include <string> #include <utility> #include <iterator> #include <algorithm> int main()
18
by: subramanian100in | last post by:
Consider a class that has vector< pair<int, string>* c; as member data object. I need to use operator>to store values into this container object and operator<< to print the contents of the...
83
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.