I am new to c++. I want to create bank account. I want the first created bank account to have the account number 100000, the second should have 100001, the third should have 100002 and so on. I wrote a program but the value of "number" doesn't change. Every bank account has the number 100000. I am not sure how to solve the problem.
.h-File
#include <iostream>
#include <string>
using namespace std;
#ifndef _ACCOUNT_H
#define _ACCOUNT_H
class account
{
private:
string name;
int accNumber;
int number= 100000;
double balance;
double limit;
public:
void setLimit(double limit);
void deposit(double amount);
bool withdraw(double amount);
void printBalance();
account(string name);
account(string name, double limit);
};
.cpp-File
#include <iostream>
#include <string>
#include "account.h"
using namespace std;
account::account(string name) {
this->name= name;
accNumber= number;
number++;
balance= 0;
limit = 0;
}
account::account(string name, double amount) {
this->name= name;
accNumber = number;
number++;
balance= 0;
limit = amount;
}
void account::setLimit(double limit) {
this->limit = limit;
}
.
.
.
.
.