arrays - C++ Output list of objects with loop -


lets have bunch of objects called customer1 - customer4

i want able list these objects loop can display details 1 after other. here constructors i've used make these objects:

customers *customer1 = new customers("eric eddinger", "713 pleasant street, crown point, sa 2304", "83885445","mr"); customers *customer2 = new customers("jackson jean", "2311 mill road, irwin, sa 3363", "8665421","mr"); customers *customer3 = new customers("maye min", "5 evergreen lane, wisconsin, wa 8232", "77854126","mrs"); customers *customer4 = new customers("ramon rolfes", "689 river road, bensalem, sa 1239", "87226474","mr"); 

what best way output of these objects single loop? should adding of these objects array? if how this?

here example of how assign array of customer , iterate on it:

#include <iostream>  class customer { public:     std::string m_name, m_address, m_num, m_title;      customer(std::string name, std::string address, std::string num, std::string title) :         m_name(name), m_address(address), m_num(num), m_title(title)     {} };  int main() {     customer customers[] = {         customer("eric eddinger", "713 pleasant street, crown point, sa 2304", "83885445", "mr"),         customer("jackson jean", "2311 mill road, irwin, sa 3363", "8665421", "mr"),         customer("maye min", "5 evergreen lane, wisconsin, wa 8232", "77854126", "mrs"),         customer("ramon rolfes", "689 river road, bensalem, sa 1239", "87226474", "mr")     };      (int = 0; < 4; i++)         std::cout   << "name: " << customers[i].m_name                     << " address: " << customers[i].m_address                     << " num: " << customers[i].m_num                     << " title: " << customers[i].m_title << std::endl;      return 0; } 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -