- for (unsigned i = 0; i < accounts.size(); i++) {
- if (accounts[i] == a) {
- accounts.erase(accounts.begin() + i);
- return NULL;
- }
+ return *(accounts.at(i_active));
+}
+
+void Account::setActive(int i)
+{
+ if ((i >= 0) && (i < int(accounts.size()))) {
+ i_active = i;
+ } else {
+ cerr << "Tried to set active account to " << i << " but there is not such account" << endl;
+ i_active = -1;
+ }
+}
+
+void Account::destroyActive()
+{
+ if ((i_active >= 0) && (i_active < int(accounts.size()))) {
+ accounts.erase(accounts.begin() + i_active);
+ i_active = -1;
+ } else {
+ cerr << "Tried to destroy active account " << i_active << " but there is not such account" << endl;
+ i_active = -1;