#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
class members
{
private:
int Age;
int Money;
public:
void setAge(int age) {Age=age;}
void setMoney(int money) {Money=money;}
int getAge()const {return Age;}
int getMoney()const {return Money;}
members(int age=0,int money=0): Age(age),Money(money) {}
};
int main()
{
vector<members>v_members;
for(size_t i=0,z=0;i<10;++i,++z)
{
if(z!=5) { v_members.push_back(members(50,70)); }
}
}
I wrote a litte program for a better understanding of a classvector and costructors. It should be ok but there are two questions.
- How could one insert new elements in the vector ?
- Would it be a good idea to create the vector within the class / the constructor?
If so, how could this be done and how could data then be saved in the main?