adplus-dvertising
frame-decoration

Question

Consider the following code and select the correct option:
class student
{  
 int marks;
 public : int* fun()
 { 
  return &marks; 
 }
};
main()
{
student s;
int *ptr=c.fun();
return 0;
}

a.

This code is good to go

b.

This code may result in undesirable conditions

c.

This code will generate error

d.

This code violates encapsulation

Answer: (d).This code violates encapsulation

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. Consider the following code and select the correct option: