C ++中的(*)语法是什么意思? [英] What does the (*) syntax in C++ mean?

查看:73
本文介绍了C ++中的(*)语法是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下语法是什么意思?

set<element*, bool (*) (element *, element *)> * getNumbers();

我对(*)部分不熟悉.任何解释都很好.谢谢

I'm not familiar with the (*) part. Any explanation would be great. Thanks

推荐答案

此处表示第二个模板参数是函数指针:

Here it means that the second template parameter is a function pointer:

bool (*) (element *, element *)

是指向带有两个 element * s并返回 bool 的函数的指针".

is "pointer to a function that takes two element*s and returns bool".

您可能还会看到与数组指针有关的(*)

You may also see (*) in connection with pointers to arrays;

int (*) [32]

是类型指向32个 int s的数组的指针".

is the type "pointer to an array of 32 ints".

这篇关于C ++中的(*)语法是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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