Analyze the code

Which of these code snippets are valid examples of rvalue expressions in C++?

1.

int a;
int& sample () 
{
 return a;
}
 
sample() = 1;

2.

int a;
int sample ()
{
 return a;
}
sample;
Options
  1. Only 1
  2. Only 2
  3. Both 1 and 2
  4. Neither 1 nor 2

Related Posts