I have a bit of code that looks something like this:
class MyClass
{
void doSomething(std::string& stringvar) {
// Does something
}}
class AnotherClass
{ /* Some data structure */ }
And then in the main, the programmer calls
MyClass* Class1;
std::string myString = "something";
AnotherClass* SecondClass;
SecondClass = (*Class1).doSomething(myString);
My question is, what does this do, since I am defining a pointer that points to nothing and then setting its value? To what does it set a value to? A random memory slot? And where? In stack or heap? And why would someone create a class only to write a function that does something? I don't really understand the class MyClass, is it possible that doSomething actually fills some data structure? If yes, then how and where if it is also a pointer that points to nothing?