C + + points to member function pointer issues

Source: Internet
Author: User

member function pointers are different from regular pointers, and a pointer to a member variable does not point to a memory location. It is usually the clearest practice to see pointers to data members as an offset.

Class Ru_m {public:    typedef int (ru_m::* p) ();    P Get_m ();    int show ();}; int Ru_m::show () {    return 10000;} Ru_m::p ru_m::get_m () {    ru_m::p vc;//Error When an object is pointing to a relative address, a non-memory address//So, the ru_m->show fetch operation is not valid in the C + + standard, but ru_m:: Show for pointing to a specific member function, non-object, for actual memory address//But in Windows Ru_m->show can be normal, let people no language.   vc=& (ru_m->show);    vc=&ru_m::show;    return VC;}

Windows is different from Linux ...

C + + points to member function pointer issues

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.