简体   繁体   English

*是c ++函数名?

[英]* is c++ function name?

While browsing the Genode source code documentation, I came across a function who's name started with an asterisk (*), specifically, 在浏览Genode源代码文档时,我遇到了一个以星号(*)开头的函数,具体来说,

Hello::Session_component *_create_session(const char *args)

I typically work in C, not C++ so am a little confused by this. 我通常使用C语言,而不是C ++,所以对此有点困惑。 Is this a pointer to a function named _create_session(), is the * part of the function name, or something else completely? 这是一个指向名为_create_session()的函数的指针,是函数名称的*部分,还是其他完全?

You can find the code example here . 您可以在此处找到代码示例。

The function is named _create_session, and its return type is a pointer to a Hello::Session_component. 该函数名为_create_session,其返回类型是指向Hello :: Session_component的指针。

This works just as it does in C: 这与C中的一样:

T *func();  // return type is T*
T* func();  // exact same declaration

*表示返回类型而不是方法名称,在这种情况下它返回Hello::Session_component* ,因此指向Session_component的指针。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM