cannot instantiate abstract
הארור הזה מתקבל ב main .main.cpp
#pragma once #define N 3 #include "BankAccount.h" #include "CheckAccount.h" #include "SavingAccount.h"int CBankAccount::a_id=0; int main() { int num,account=0; CBankAccount *arrPBank; do { cout<<"Enter your choice : \n\n"; cout<<"1. Create new account.\n"; cout<<"2. Redraw.\n"; cout<<"3. Deposit.\n"; cout<<"4. Account/s with the highest balance.\n"; cout<<"5. Print account.\n"; cout<<"6. Exit.\n"; cin>>num; switch(num) { case 1: cout<<"Enter your choice : \n\n"; cout<<"1.Saving Account. \n"; cout<<"2.Check Account. \n"; cin>>num; if(num == 1 || num == 2) { if(num == 1) { int id; string name; cout<<"Enter client ID : \n"; cin>>id; cout<<"Enter Name : \n"; getline(cin,name); arrPBank=new SavingAccount(name,id); account++; } else { int id,cradit; string name; string auth; cout<<"Enter client ID : \n"; cin>>id; cout<<"Enter name : \n"; getline(cin,name); cout<<"Enter authorized name : \n"; getline(cin,auth); cout<<"Enter cradit : \n"; cin>>cradit; arrPBank=new CheckAccount(name,id,auth,cradit); account++; } } else cout<<"Wrong choice. \n"; case 2: case 3: case 4: case 5: case 6: ; } }while (num != 6); return 0; }
|
BankAccount.h
#pragma once #include <iostream> #include <string> using namespace std;class CBankAccount { protected : static int a_id; string name; int c_id; int a_num; double balance; public: CBankAccount(string,int); virtual ~CBankAccount(void);
int get_aid (){return a_id;}; double get_balance(){return balance;}; int get_anum(){return a_num;}; //int c_id(){return c_id;}; virtual void deposit()=0; virtual void redraw()=0; bool operator > (const CBankAccount&); };
|
הפונקציות של ההפקדה והמשיכה ממומשות בשני המחלקות היורשות
השגיאה מכוונת ל שורה :
arrPBank=new CheckAccount(name,id,auth,cradit);
|
