I'm about one week into studying C++ so please bear with me.
So let us say that I have a function that returns a value that I need to use in another function.
Is it better practice for one to assign the returned value to another variable first or is it better to simply call the function as a parameter of the other? Both of which should be valid syntax (I think).
//method 1 int x = foo(boo(1)); //method 2 int a = boo(1); int x = foo(a);
I'm starting to need to use functions that involve many parameters, and I can see how method 1 could potentially lead to more confusing code.
//ResolveProcess is a function that resolves dwProcessId using an input //method 1 HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, ResolveProcess(processName)); //method 2 DWORD processID = ResolveProcess(processName); HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
http://www.learncpp.com doesn't have information on which is better (it usually does), so I figured I'd ask here.