my scenario is as follows::
class Parent
{
public:
int x;
}
class Child:public Parent
{
int x; // Same name as Parent\'s \"x\".
void Func()
{
this.x = Paren
It's only a brief explaination of solutions provided by Luchian Grigore and Mr. Anubis, so if you are curious 'how this works', you should read it further.
C++ provides a so-called, "scope operator" (::
), which is perfectly suited to your task.
More details are provided at this page. You can combine this operator with class name (Parent
) to access parent's x
variable.