There are no "files" in a program; all the object code is linked together.
I'm trying to optimize RAM usage. |
Don't. Not yet. Have you shown that memory is an issue?
Your questions imply that you don't even know how memory is used.
Executable instructions and literal values are in the memory whether they are used or not.
Data (values) gets allocated memory (stack, heap, free store) as needed.
Lifetime of objects depends on whether they are automatic, dynamic, global, etc.
1 2 3 4 5 6 7 8 9 10
|
void foo( const T & );
int main() {
T bar;
foo( bar );
}
void foo( const T & gaz ) {
// use gaz
}
|
The implementation of foo() can be in "separate file".
It is sufficient that main() knows the declaration of foo();
Both main() and foo() must see definition of T.
There is only one object, "bar".