一个C ++ operator()问题 [英] A C++ operator() question

查看:158
本文介绍了一个C ++ operator()问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一些使用我认为的operator()的代码,其方式与我见过的不同。我原以为:

I have discovered some code that uses what I think is operator() in a different way than any I've seen. I was expecting:

HDC operator()() { return dcC; }



哪个有效,但他们有:


Which works, but they had:

operator HDC() { return dcC; }



这第二种形式叫什么,在哪里可以找到更多相关信息?我看不到我的任何一本书,但也许我使用了错误的术语。



谢谢!


What is this second form called, and where to find out more about it? It isn't in any of my books that I can see, but maybe I'm using the wrong term.

Thanks!

推荐答案

在第一种形式中,HDC是返回类型,第二种形式是通过隐式类型转换获取HDC的正确语法。



wikipwdia 带来了一些清晰度。



请显示如何在C ++中使用第一个:-O
In the first form HDC is the return type, in the second form is correct syntax for getting HDC via implicit type cast.

The wikipwdia brings some clarity.

please show coe how to use the first in C++ :-O


这篇关于一个C ++ operator()问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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