VC in the::

Source: Internet
Author: User


:: Is the "scope decomposition operator" in C + +. For example, declaring a Class A, Class A declares a member function VOIDF (), but does not give the definition of F in the declaration of the class, then the definition of f in the class is written as Voida::f (), which means that the F () function is a member function of Class A.
:: There is generally a use, is directly used in the global function before, the expression is a global function. When a member function of a class has the same name as a global function outside of a class, the test, when the big hint is defined within the class, calls the function name by default as its own member functions; If you want to invoke a global function of the same name, you must hit:: To make a difference. For example, in VC, you can call the API functions, in the API function name before adding::

In the PX4 code, for example.

void
Px4fmu::task_main ()
{
......................................................................................................................... .............

/* Sleep waiting for data, stopping to check for PPM
* Input at 50Hz * *
int ret =::p oll (_poll_fds, _poll_fds_num, Control_input_drop_limit_ms);

......................................................................................................................... ....................................

}

:: What is the use, obviously, of calling a global function, not a function of the class itself. By looking at the code can be found. Class Px4fmu:public Device::cdev, while classes Cdev
There are member functions: int cdev::p oll (struct file *filp, struct POLLFD *fds, bool setup).


So where is the global function? In FS/FS_POLL.C int poll (FAR struct POLLFD *fds, nfds_t nfds, int timeout).


In fact, you can also see from the parameters of the function that you should call the global function, not the class itself.

Finally figured it out.

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.