1//===-- main.cpp ------------------------------------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10#include <string> 11#include <vector> 12#include <iostream> 13 14class NameAndAddress 15 { 16 public: 17 std::string& GetName() { return *m_name; } 18 std::string& GetAddress() { return *m_address; } 19 NameAndAddress(const char* N, const char* A) : m_name(new std::string(N)), m_address(new std::string(A)) 20 { 21 } 22 ~NameAndAddress() 23 { 24 } 25 26 private: 27 std::string* m_name; 28 std::string* m_address; 29}; 30 31typedef std::vector<NameAndAddress> People; 32 33int main (int argc, const char * argv[]) 34{ 35 People p; 36 p.push_back(NameAndAddress("Enrico","123 Main Street")); 37 p.push_back(NameAndAddress("Foo","10710 Johnson Avenue")); // Set break point at this line. 38 p.push_back(NameAndAddress("Arpia","6956 Florey Street")); 39 p.push_back(NameAndAddress("Apple","1 Infinite Loop")); 40 p.push_back(NameAndAddress("Richard","9500 Gilman Drive")); 41 p.push_back(NameAndAddress("Bar","3213 Windsor Rd")); 42 43 for (int j = 0; j<p.size(); j++) 44 { 45 NameAndAddress guy = p[j]; 46 std::cout << "Person " << j << " is named " << guy.GetName() << " and lives at " << guy.GetAddress() << std::endl; 47 } 48 49 return 0; 50 51} 52 53