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
Release: 2024-05-09 17:22:37
forward
414 people have browsed it

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!

source:zol.com.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!