::(成员方法名称)在C ++中做什么 [英] What does ::(member method name) do in c++

查看:81
本文介绍了::(成员方法名称)在C ++中做什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是c ++的入门者,我正在尝试开发一个简单的OpenGL应用程序.查看互联网上的一些代码,我发现了这一点:

I'm an starter at c++, and I'm trying to develop a simple OpenGL application. Looking at some code on the internet I found this:

::glutDisplayFunc(myPixmap::drawCallback);

忽略函数本身,我只想知道该行代码的功能.它会调用该函数吗?我知道这可能是一个愚蠢的问题,但我找不到答案

Ignore the function itself, i just wanted to know what that line of code does. Does it call the function? I know it's probably a silly question, but I can't find the answer

推荐答案

:: 是范围解析运算符.

如果容器(名称空间或类)名称出现在其前面,则它将导致编译器仅在该容器内部查找指定的标识符.这是从类外部引用类的静态成员的方法.

If a container (namespace or class) name appears before it, it causes the compiler to only look inside that container for the specified identifier. This is the way to refer to static members of a class from outside the class.

如果它首先出现,但前面没有名称,则意味着要查看全局名称空间.

If it appears first, without a name in front, it means to look in the global namespace.

您的示例代码似乎包含两种用法.该行代码称为 :: glutDisplayFunc .但是没有调用其他函数 myPixmap :: drawCallback .地址已保存,以备后用.

Your example code appears to be contain both usages. That line of code calls ::glutDisplayFunc. But the other function, myPixmap::drawCallback, isn't called. It's address is saved for later.

这篇关于::(成员方法名称)在C ++中做什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆