Names of C + + subclasses and parent class member functions

Source: Internet
Author: User
  1. The subclass and parent class return value parameters are the same, the function name is the same, and the virtual keyword is the type of the object that determines which function is called.
  2. Subclasses and parent classes as long as the function name is the same, without the virtual keyword, the object of the subclass has no way to call a function with the same name as the parent class, the parent class has a function with the same name hidden, or you can force calling the parent class with the same name function Class::funtion_name.
  3. Subclass and Parent class parameters are different, the function name is the same, there is the virtual keyword, there is no polymorphism, the object of the subclass has no way to call the parent class with the same name function, the parent class has the same name function is hidden, you can also force call the parent class with the same name function Class::funtion_name.
  4. The subclass and the parent return values are different, the parameters are the same, the function names are the same, there is the virtual keyword, then the compiler error Error C2555 compiler does not allow the function name parameter the same return value different function overloads.

Names of C + + subclasses and parent class member functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.