Home  >  Article  >  Software Tutorial  >  How does a subclass in vs2017 access the static member of the parent class with the same name_visual studio subclass accesses the static member method of the parent class with the same name

How does a subclass in vs2017 access the static member of the parent class with the same name_visual studio subclass accesses the static member method of the parent class with the same name

PHPz
PHPzforward
2024-05-09 17:22:37480browse

For Visual Studio developers, accessing static members of a parent class with the same name in a child class can be a confusing issue. PHP editor Xigua will analyze this problem in depth, explaining how subclasses access static members of parent classes, as well as potential pitfalls and solutions in different situations. Through this guide, PHP editor Xigua aims to help readers understand the nature of this problem and provide practical guidance to make their code clearer and more efficient.

First create a new parent class Transportation and set a static member m_Speed.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

Then create a subclass that inherits the parent class Transportation, and also sets a static member m_Speed.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

Then create an instance object of the subclass in the main function.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

Then use this object to access the static member with the same name in the parent class.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

Click [Local Windows Debugger] at the top.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

Run the program and view the results.

vs2017子类怎么访问父类同名静态成员_visual studio子类访问父类同名静态成员方法

The above is the detailed content of How does a subclass in vs2017 access the static member of the parent class with the same name_visual studio subclass accesses the static member method of the parent class with the same name. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:zol.com.cn. If there is any infringement, please contact admin@php.cn delete