mardi 7 juillet 2020

I get all these error messages that say 'undefined reference to Bank::open(int),and its like that for all the functions in my two classes [duplicate]

I get all these error messages that say 'undefined reference to Bank::open(int),and its like that for all the functions in my two classes.Here are the error messages.Can the erroe in my code be fixed enter image description here. Here is the code for all the classes in my project

basic_bank.cpp

#ifndef BASIC_BANK_H
#define BASIC_BANK_H
#include "BASIC_BANK.H"
#include<bits/stdc++.h>


class Bank
{
  /*  public:
        Basic_Bank();
        virtual ~Basic_Bank();

    protected:

    private:*/
    protected:
    int ac_no,account;
    float balance;
   std::string name;
    std::string account_type;
    long int phone_no;
    std::string email;
    std::string date_of_birth;
    std::string address;

public:

    Bank();
    //{ }
//Constructor was suppose to be used for creating account but I got an error in main while trying to use it
//Kinda redundant now
   // Bank(int acn,float bl,std::string nme,std::string ac_tp,long int phn,std::string em,std::string d_o_b,std::string add):account(acn),balance(bl),name(nme),account_type(ac_tp),phone_no(phn),email(em),date_of_birth(d_o_b),address(add)
   // { }



    void open(int);
    void deposit(int);
    void withdraw(int);
    void display(int);
    void display_all();
    void update(int);
    void ac_delete(int);

    //get_and set functions

    void set_account(int);
    void set_balance(float);
    void set_name(std::string);
    void set_account_type(std::string);
    void set_phone_no(long int);
    void set_email(std::string);
    void set_date_of_birth(std::string);
    void set_address(std::string);

    int get_account();
    float get_balance();
    std::string get_name();
    std::string get_account_type();
    long int get_phone_no();
    std::string get_email();
    std::string get_date_of_birth();
    std::string get_address();
};

#endif // BASIC_BANK_H

basic_bank.h

#ifndef BASIC_BANK_H
#define BASIC_BANK_H
#include "BASIC_BANK.H"
#include<bits/stdc++.h>


class Bank
{
  /*  public:
        Basic_Bank();
        virtual ~Basic_Bank();

    protected:

    private:*/
    protected:
    int ac_no,account;
    float balance;
   std::string name;
    std::string account_type;
    long int phone_no;
    std::string email;
    std::string date_of_birth;
    std::string address;

public:

    Bank();
    //{ }
//Constructor was suppose to be used for creating account but I got an error in main while trying to use it
//Kinda redundant now
   // Bank(int acn,float bl,std::string nme,std::string ac_tp,long int phn,std::string em,std::string d_o_b,std::string add):account(acn),balance(bl),name(nme),account_type(ac_tp),phone_no(phn),email(em),date_of_birth(d_o_b),address(add)
   // { }



    void open(int);
    void deposit(int);
    void withdraw(int);
    void display(int);
    void display_all();
    void update(int);
    void ac_delete(int);

    //get_and set functions

    void set_account(int);
    void set_balance(float);
    void set_name(std::string);
    void set_account_type(std::string);
    void set_phone_no(long int);
    void set_email(std::string);
    void set_date_of_birth(std::string);
    void set_address(std::string);

    int get_account();
    float get_balance();
    std::string get_name();
    std::string get_account_type();
    long int get_phone_no();
    std::string get_email();
    std::string get_date_of_birth();
    std::string get_address();
};

#endif // BASIC_BANK_H

loan.cpp

#include "LOAN.H"
#include "BASIC_BANK.H"
#include<bits/stdc++.h>
//Loan::Loan()
//{
    //ctor
//}

//Loan::~Loan()
//{
    //dtor
//}
Loan::calculates_interest(int a,int y,int r)
{
           cout<<"INTEREST DUE:"<<endl;

           cout<<a*(r/100)*y<<endl;
}
Loan::tests_qualification_for_loan(long int income)
{
        if(income<1000)
        {
            cout<<"NOT ELIGIBLE FOR ANY PLAN"<<endl;
            return 0;

        }
        else if(income<2000)
        {
            cout<<"ELIGIBLE FOR PLAN_1 "<<endl;
        }
        else if(income<3000)
        {
            cout<<"ELIGIBLE FOR PLAN_1 AND PLAN_2 "<<endl;
        }
        else if(income<4000)
        {
            cout<<"ELIGIBLE FOR ALL AVAILABLE PLANS "<<endl;
        }



}
void Loan::take_loan()
{

        int ac;
        long int am;
        int t;
        int in;

        cout<<"ENTER ACCOUNT NUMBER"<<endl;
        cin>>ac;
        cout<<"CHOOSE PLAN:"<<endl;

        cout<<"PLAN_1                       PLAN_2                        PLAN_3
        cout<<"AMOUNT : 50,000 tk| AMOUNT : 150,000 tk|  AMOUNT : 200,000 tk"<<endl;
        cout<<"TERM : 2 YEARS       | TERM : 3 YEARS         |  TERM : 3.5 YEARS                "<<endl;
        cout<<"INTEREST RATE:2%|  INTEREST RATE:3%  |   INTEREST RATE:3.25%          "<<endl;
        int plan;
        if(plan==1)
        {
            a=50,000;
            t=2;
            in=2;
                    }
        else if(plan==2)
        {
            a=150,000;
            t=3;
            in=3;
                    }
                else if(plan==3)
        {
            a=200,000;
            t=3.5;
            in=3.25;
                    }


          ofstream Loan_Records("Loan_record.txt");
           Loan_Records.open("Loan_record.txt",Loan_Records.app);

                {




                 Loan_Records<<ac<<" "<<am<<" "<<t<<" "<<in<<endl;
                }

}
void Loan::pending()
{

    int acc;
    int t;
    int l_a;
    int i_r;
    Loan l[20];

    int act;
    cout<<"ENTER ACCOUNT NUMBER:"<<endl;
    cin>>act;
    //opens file to save info
    fstream File;
    File.open("Loan_record.txt");
    //saves info into objects
    int i=0;
    while(File>>acc>>l_a>>t>>i_r)
    {
        l[i].ac_no=acc;
        l[i].loan_amount=l_a;
         l[i].term=t;
         l[i].interest=i_r;
        i++;
    }
    File.close();
     int flag=0;
    for(int k=0;k<i;k++)
    {
        if(l[k].ac_no==act)
        {
            flag=1;
            cout<<"LOAN AMOUNT:  "<<    l[k].loan_amount<<endl;
            cout<<"TERM: "<<  l[k].term<<endl;
            cout<<"INTEREST: "<<l[k].interest<<"per annum"<<endl;
        }
    }
    if(flag==0)
    {
        cout<<"NO LOAN PENDING"<<endl;
    }

}

loan.h

#include "LOAN.H"
#include "BASIC_BANK.H"
#include<bits/stdc++.h>
//Loan::Loan()
//{
    //ctor
//}

//Loan::~Loan()
//{
    //dtor
//}
Loan::calculates_interest(int a,int y,int r)
{
           cout<<"INTEREST DUE:"<<endl;

           cout<<a*(r/100)*y<<endl;
}
Loan::tests_qualification_for_loan(long int income)
{
        if(income<1000)
        {
            cout<<"NOT ELIGIBLE FOR ANY PLAN"<<endl;
            return 0;

        }
        else if(income<2000)
        {
            cout<<"ELIGIBLE FOR PLAN_1 "<<endl;
        }
        else if(income<3000)
        {
            cout<<"ELIGIBLE FOR PLAN_1 AND PLAN_2 "<<endl;
        }
        else if(income<4000)
        {
            cout<<"ELIGIBLE FOR ALL AVAILABLE PLANS "<<endl;
        }



}
void Loan::take_loan()
{

        int ac;
        long int am;
        int t;
        int in;

        cout<<"ENTER ACCOUNT NUMBER"<<endl;
        cin>>ac;
        cout<<"CHOOSE PLAN:"<<endl;

        cout<<"PLAN_1                       PLAN_2                        PLAN_3
        cout<<"AMOUNT : 50,000 tk| AMOUNT : 150,000 tk|  AMOUNT : 200,000 tk"<<endl;
        cout<<"TERM : 2 YEARS       | TERM : 3 YEARS         |  TERM : 3.5 YEARS                "<<endl;
        cout<<"INTEREST RATE:2%|  INTEREST RATE:3%  |   INTEREST RATE:3.25%          "<<endl;
        int plan;
        if(plan==1)
        {
            a=50,000;
            t=2;
            in=2;
                    }
        else if(plan==2)
        {
            a=150,000;
            t=3;
            in=3;
                    }
                else if(plan==3)
        {
            a=200,000;
            t=3.5;
            in=3.25;
                    }


          ofstream Loan_Records("Loan_record.txt");
           Loan_Records.open("Loan_record.txt",Loan_Records.app);

                {




                 Loan_Records<<ac<<" "<<am<<" "<<t<<" "<<in<<endl;
                }

}
void Loan::pending()
{

    int acc;
    int t;
    int l_a;
    int i_r;
    Loan l[20];

    int act;
    cout<<"ENTER ACCOUNT NUMBER:"<<endl;
    cin>>act;
    //opens file to save info
    fstream File;
    File.open("Loan_record.txt");
    //saves info into objects
    int i=0;
    while(File>>acc>>l_a>>t>>i_r)
    {
        l[i].ac_no=acc;
        l[i].loan_amount=l_a;
         l[i].term=t;
         l[i].interest=i_r;
        i++;
    }
    File.close();
     int flag=0;
    for(int k=0;k<i;k++)
    {
        if(l[k].ac_no==act)
        {
            flag=1;
            cout<<"LOAN AMOUNT:  "<<    l[k].loan_amount<<endl;
            cout<<"TERM: "<<  l[k].term<<endl;
            cout<<"INTEREST: "<<l[k].interest<<"per annum"<<endl;
        }
    }
    if(flag==0)
    {
        cout<<"NO LOAN PENDING"<<endl;
    }

}

main.cpp

#include <bits/stdc++.h>
#include "BASIC_BANK.H"
#include "LOAN.H"
using namespace std;

int main()
{
    cout<<"\n"<<endl;
    cout<<"*********************BANK MANAGEMENT SYSTEM*********************"<<endl;
    cout<<"\n\n"<<endl;
    int i,j,w,m,l,y=0,o,ad;

    Bank b[20];
    Loan Lo[20];
    int index;
    do
    {
        cout<<"______________________________________________________________\n"<<endl;
        cout<<"  PRESS 1    TO   OPEN ACCOUNT       "<<endl;
        cout<<"  PRESS 2    TO   DEPOSIT MONEY"<<endl;
        cout<<"  PRESS 3    TO   WITHDRAW MONEY"<<endl;
        cout<<"  PRESS 4    TO   DISPLAY  INFORMATION  OF ALL ACCOUNTS"<<endl;
        cout<<"  PRESS 5    TO   DISPLAY INFORMATION   OF  A SPECIFIC ACCOUNT"<<endl;
        cout<<"  PRESS 6    TO   UPDATE ACCOUNT INFORMATION"<<endl;
        cout<<"  PRESS 7    TO  CLOSE AN ACCOUNT"<<endl;
        cout<<"  PRESS 8    TO  TAKE LOAN"<<endl;
        cout<<"  PRESS 9    TO   EXIT"<<endl;

        cin>>index;

        switch(index)
        {

        case 1:
        {
           cout<<"HOW MANY ACCOUNTS DO YOU WANT TO OPEN"<<endl;
            cin>>y;

           // for(i=0; i<y; i++)*/
            {
                b[i].open(y);
               // break;


                //Bank c[i].(a,b,n,t,ph,e,d,ads);
                //tried using above constructor but got error saying ''expected initializer before '.' token
            }
            cout<<"Account Creation Successful"<<endl;
            break;
        }

        case 2:
        {
            cout<<"ENTER ACCOUNT NUMBER"<<endl;
            cin>>j;


                b[i].deposit(j);

            break;
        }
        case 3:
        {
            cout<<"ENTER YOUR ACCOUNT NUMBER"<<endl;
            cin>>w;
            //for(i=0; i<y; i++)
          //  {
                b[i].withdraw(w);
            //}
            break;
        }
        case 4:
        {

            //for(i=0; i<y; i++)
            //{
                b[i].display_all();
            //}
            break;

        }
        case 5:
        {
            cout<<"Enter your account number"<<endl;
            cin>>m;

            {
                b[i].display(m);
            }
        }
        case 6:
        {
            cout<<"ENTER ACCOUNT NUMBER"<<endl;
            cin>>o;
           // for(i=0; i<y; i++)
            {
                b[i].update(o);
            }
        }
        case 7:
        {
            cout<<"ENTER ACCOUNT NUMBER"<<endl;
            cin>>ad;
            b[i].ac_delete(ad);
            break;
        }
        case 8:
            {

                long int inc;
                long int flag;
                cout<<"ENTER MONTHLY INCOME"<<endl;
                cin>>inc;
                flag=Lo[i].tests_qualification_for_loan(inc);
                    if(flag==0)
                    {
                        cout<<"***"<<endl;
                    }
                    else
                    {
                      Lo[i].take_loan();
                     }
            }
               case 9:
            {

                exit(0);
            }
        default:
        {
            cout<<"WRONG KEY.PLEASE TRY AGAIN"<<endl;
            break;
        }
        }
    }
    while(1);

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire