1

My Problem here is that i have initialized a function mainscr() which on a condition call vdetails(). but as the code is shown below the program doesn't compile because of either of the functions is not initialized before the other. If i keep mainscr() on top of vdetails() mainscr will not run but vdetails() will because mainscr() is initialized before. Can anyone suggest me on how i can declare the function as to be used from anywhere.

Tried using Header file in which already vdetails() is included but getting error like include nested too deep.

void mainscr()
{
    stringstream foos (detamt);
    foos >> detamto;
    char flago;
    cout<<"Welcome To Maxon Bank Banking Portal"<<endl<<endl;
    cout<<"  Please Choose From the Following: "<<endl<<endl;
    cout<<"  1. View Details "<<endl<<endl; cout<<"  2. Check Balance"<<endl<<endl;
    cout<<"  3. Deposit Cash "<<endl<<endl; cout<<"  4. Withdraw Cash "<<endl<<endl;
    cout<<"  Option: ";
    cin>>flago;
    if (flago=='1')
    {
        vdetails();
    }

void vdetails()
{
   system("cls");
        cout<<"Maxon Bank Banking Portal"<<endl<<endl;
        cout<<"  "<<detacno<<endl<<endl;
        cout<<"  "<<detn<<endl<<endl;
        cout<<"  "<<detactype<<endl<<endl;
        cout<<"  AVAILABLE BALANCE: INR "<<detamto<<endl<<endl;
        Cont();
        system("cls");
        mainscr();
}

Actually i am trying to ask user their input if input is 1 then that will show them their account details and go back to mainscr() where this thing will happen again if input is same.

Maddox Mania
  • 61
  • 1
  • 7

1 Answers1

3

You need to make a forward reference which is basically the signature of the function without body.

void mainscr();
void vdetails();

Put those above your implemenations (or better in the corresponding header) and your functions know each other

Narase
  • 490
  • 2
  • 12
  • Actually Ive been developing since a month so dint know it. – Maddox Mania Jun 25 '19 at 08:23
  • Please note that term "forward reference" is [misleading](https://en.cppreference.com/w/cpp/language/reference#Forwarding_references) in this context. See also https://stackoverflow.com/questions/44087145/difference-between-prototype-declaration-and-forward-declaration – Bob__ Jun 25 '19 at 08:39