I am new to C++ and I am trying to understand some code. What does it mean to have a * in front of the datatype ? and why is the class Name in front of the method name CAStar::LinkChild
void CAStar::LinkChild(_asNode *node, _asNode *temp)
{
}
A * in front of the data type says that the variable is a pointer to the data type, in this case, a pointer to a node. Instead of passing a copy of the entire "node" into the method, a memory address, or pointer, is passed in instead. For details, see Pointers in this C++ Tutorial.
The class name in front of the method name specifies that this is defining a method of the CAStar
class. For details, see the Tutorial pages for Classes.
The *
means that it's a pointer. You will also find that _asNode *node
is equivalent to _asNode* node
.
The class name is in front of the method name when the method is not defined inside the class { ... }
. The ::
is the scope operator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With