[ create a new paste ] login | about

Link: http://codepad.org/hAumqzNB    [ raw code | output | fork ]

C++, pasted on Jun 14:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Person {
	string name;
	int age;
};

int main()
{
	// Populate some people and put them into a vector.

	Person p1, p2, p3;
	vector<Person> ListOfPeople;

	p1.name = "Richard";
	p2.name = "Mike";
	p3.name = "Cheryl";

	p1.age = 12;
	p2.age = 13;
	p3.age = 14;

	ListOfPeople.push_back(p1);
	ListOfPeople.push_back(p2);
	ListOfPeople.push_back(p3);

	vector<Person>::const_iterator citer = ListOfPeople.begin();

	while ( citer != ListOfPeople.end() )
	{
		cout << (*citer).name << " is " << citer->age << " years old." << endl;
		++citer;
	}

	return 0;
}


Output:
1
2
3
Richard is 12 years old.
Mike is 13 years old.
Cheryl is 14 years old.


Create a new paste based on this one


Comments: