Which of the following statement(s) is/are correct?a)* operator is use...
Explanation:
a) * operator is used to declare a reference:
This statement is incorrect. The * operator is used to declare a pointer, not a reference. References are declared using the & operator. For example:
```
int num = 10;
int &ref = num; // declaring a reference
```
b) A reference variable defined to refer a particular variable can refer to any other variable also:
This statement is correct. Once a reference variable is defined to refer to a particular variable, it can later refer to any other variable of the same type. For example:
```
int num1 = 10;
int num2 = 20;
int &ref = num1; // ref refers to num1
ref = num2; // ref now refers to num2, num1 is unchanged
```
In the above example, initially the reference variable `ref` is referring to `num1`. But later, it is assigned to `num2`, so now `ref` refers to `num2` instead.
c) References must always be initialized inside classes:
This statement is incorrect. References can be declared and initialized inside classes, but they are not limited to being initialized only inside classes. References can be declared and initialized in any scope where variables are allowed. For example:
```
void function() {
int num = 10;
int &ref = num; // reference initialized inside a function
}
```
In the above example, the reference variable `ref` is declared and initialized inside the `function()`.
d) A variable can have more than one references:
This statement is correct. A variable can have multiple references pointing to it. This means that multiple reference variables can be declared and initialized to refer to the same variable. Any changes made through one reference will be reflected in the original variable and can be accessed through other references as well. For example:
```
int num = 10;
int &ref1 = num; // first reference
int &ref2 = num; // second reference
ref1 = 20; // num and ref2 will also be 20
```
In the above example, both `ref1` and `ref2` are references to `num`. So any changes made through `ref1` will also be reflected in `num` and `ref2`.
Which of the following statement(s) is/are correct?a)* operator is use...
A variable can have multiple references as references are nothing just another name for a variable hence a variable can more than one references.
To make sure you are not studying endlessly, EduRev has designed Class 7 study material, with Structured Courses, Videos, & Test Series. Plus get personalized analysis, doubt solving and improvement plans to achieve a great score in Class 7.