No when my doSomething function in class is calling the myFoo() function defined in main.cpp it is not working and giving error? How can I call this function in class can anyone tell me?
Because class does not know about this function existence. You can forward declare it in mainMemory.h, but usually the need to call function outside class is indicator of bad program design.