Why not class calling the main's function?

May 10, 2013 at 5:56am
Ok guys I want your help in my programming assignment.

I have two files, main.cpp and a class file, i.e. mainMemory.h

I have programming struction like this.

1
2
3
4
5
6
7
8
9
10
11
12
main.cpp

#include <iostream>
#include "mainMemory.h"

////******My Function Definition Here************//////////(myFoo())

int main ()
{
   mainMemory obj;
   obj.doSomething();
}


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?
May 10, 2013 at 6:08am
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.
Topic archived. No new replies allowed.