What is the error in the following code? Why is this wrong?

```
int f(int x)
{
int x;
// code for function body
}
```


The declaration of the variable x in the function body will be flagged by the compiler as a multiple declaration of the variable Such an attempt at (re)declaring a parameter violates the C++ rule that all identifiers be declared exactly once, prior to use. The g++ compiler gives the following (somewhat cryptic) error messages. (The -fsyntax-only option is to cause checking the programs syntax, but not generate any other files in the event that there are no errors. Most compilers have a similar option.)
g++ -fsyntax-only Problem10.cc
Problem10.cc: In function `int f(int)':
Problem10.cc:3: declaration of `x' shadows a parameter
Compilation exited abnormally with code 1 at Mon Jul 10 07:10:07

Computer Science & Information Technology

You might also like to view...

A(n) ____ variable can serve as a condition in an if or while statement.

A. String B. Boolean C. Object D. Number

Computer Science & Information Technology

You can change the color of your Calendar using the Color button in the View tab.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Pharming most often takes place via a company's DNS server, which routes Web page requests corresponding to company URLs.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Which of the following virsh commands will display the total amount of memory as well as the amount of free memory for a node?

A. nodesh B. nodemem C. nodememstats D. showmem

Computer Science & Information Technology