Where are functions stored in a C++ program?
For example
int abc()
{
//where am I stored?
}
I know that we can take the address of a function, that means functions are stored somewhere in memory. But I have already read at many places that no memory allocation for functions takes place.
I am confused. My question may seem vague to many of you but I can’t help.
Before being run, your program is loaded into memory, and that includes loading the code that implements the functions.
Once the program starts to run, no memory allocation for functions takes place; it’s done before the program starts, by the system’s program loader.
This assumes a “normal” desktop OS, for embedded systems running code out of ROM, the situation is often different.