deceleration shadows parameter


when i run the program i get "error: decleration of "double BA" shadows a parameter" i havent really learned hoe to use functions yet im kinda winging it from some examples i saw. i am trying to print the value of b in the function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

double printmenu(double BA);

int main() {
    cout << "The Game of \n";
    cout << "     ___           ___           ___           ___                        \n";
    cout << "    /\\  \\         /\\  \\         /\\  \\         /\\__\\               \n";
    cout << "   /::\\  \\       /::\\  \\       /::\\  \\       /:/  /                 \n";
    cout << "  /:/\\:\\  \\     /:/\\:\\  \\     /:/\\ \\  \\     /:/__/               \n";
    cout << " /:/  \\:\\  \\   /::\\~\\:\\  \\   _\\:\\~\\ \\  \\   /::\\  \\ ___      \n";
    cout << "/:/__/ \\:\\__\\ /:/\\:\\ \\:\\__\\ /\\ \\:\\ \\ \\__\\ /:/\\:\\  /\\__\\ \n";
    cout << "\\:\\  \\  \\/__/ \\/__\\:\\/:/  / \\:\\ \\:\\ \\/__/ \\/__\\:\\/:/  /    \n";
    cout << " \\:\\  \\            \\::/  /   \\:\\ \\:\\__\\        \\::/  /          \n";
    cout << "  \\:\\  \\           /:/  /     \\:\\/:/  /        /:/  /                \n";
    cout << "   \\:\\__\\         /:/  /       \\::/  /        /:/  /                  \n";
    cout << "    \\/__/         \\/__/         \\/__/         \\/__/                   \n";
    cout << "                                                                          \n";

    double B = 0;

    printmenu(B);




    return 0;
}

double printmenu(double BA) {

    double BA;

  cout << " +------ATM------+ +-----SHOP-----+ +-----JOBS-----+      \n";
  cout << " |here you can   | |here you can  | |here you can  |      \n";
  cout << " |withdraw and   | |buy and sell  | |do jobs to    |      \n";
  cout << " |deposite money | |items         | |earn money    |      \n";
  cout << " +---------------+ +--------------+ +--------------+      \n";
  cout << "                                                          \n";
  cout << " +-------------------------------------------+ \n";
  cout << " |Your cash balance is: $" << BA << "\n";
  cout << " +-------------------------------------------+ \n";
  return (BA);
}
Last edited on
Line 36 declares a local variable inside the function that has the same name as one of the function's parameters.

Topic archived. No new replies allowed.