I just started C++ this semester and i have a horrible techer that i cant understand. And to make it even worse he is the only teacher for it at my campus. So if anyone would like to help me out. And teach me a few things i would appreciate it.
Hello I am creating a bank program for an online c++ class the instructor has not got back to me on my request any help would be appriciated. The program deals with classes and exceptions. I need to create an array of four checking account objects that calls the bank constructor which might throw an exception. I got all this done correctly I think. My problem now is I need to display which account threw the exception and display all account info only if all account numbers are good(account number must be between 1000 and 9999. here is my code
#include "stdafx.h"
#include<iostream>
#include<string>
#include<conio.h>
#include<exception>
using namespace std;
class Bank
{
protected: //Protected variables
int acctNumber;
double balance;
public:
Bank(); //constructor
void display();
};
Bank::Bank()//constuctor used to enter data
{
string message = "Account numbers must be four digits";
cout << "Enter Account Number "; cin >> acctNumber;
try
{
if(acctNumber < 1000 || acctNumber > 9999)
{
throw(message);
}
}
catch(string message)
{
cout << message << endl;
acctNumber =0;
balance =0;
}