res is a pointer to a dagnode. *res is the value of that dagnode.
* is the dereference operator which returns the value pointed to by a pointer. But it's also used to declare pointers, which is where your confusion is probably coming from.
Hey everybody.
Okay i dont exacly understand why but it works.
However i now get a problem when i call it:
dagnode search = globalDag->getVersionNode(1);
../test.cpp:46:46: error: conversion from ‘dagnode*’ to non-scalar type ‘dagnode’ requested
../test.cpp:47:45: error: base operand of ‘->’ has non-pointer type ‘dagnode’
getVersion Node(x) returns a pointer, so you need to assign the returned value to a pointer. If you just want a value you could do something like this:
dagnode search = *(globalDag->getVersionNode(1));
Or you could return the value instead of a pointer from getVersionNode().
Your second error comes from the fact that globalDag is a dagnode, not a *dagnode. To call member functions you only use '->' for pointers, otherwise use '.' :