* - C ++ function name?

While looking at the documentation for the Genode source code, I came across a function whose name began with an asterisk (*), in particular,

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

I usually work in C, not C ++, so I'm a bit confused about this. Is this a pointer to a function named _create_session (), is * part of the function name, or is it something else entirely?

Here you can find sample code here .

+3
source share
2 answers

The function is called _create_session, and its return type is a pointer to Hello :: Session_component.

This works the same as in C:

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

*refers to the type of the return value, not the name of the method, in which case it returns Hello::Session_component*, therefore a pointer to Session_component.

+4
source

Source: https://habr.com/ru/post/1784587/


All Articles