So the title is my question. In memory, arguments can be located on the stack or heap depending on how they are initialized, but how is hard-coded information dealt with?
As an example, I will use the constructor for ifstream
What is the difference between this:
void function(){
ifstream infile("home/some/file/path");
}
vs
void function(char* filePath){
ifstream infile(filePath); //filePath points to a character array which contains home/some/file/path
}
Could any memory implications arise from the use of one over the other? (Multithreading could lead to heap corruption if the char* isn't free'd correctly? etc).
I am just trying to understand the difference and possible implications so I can apply the answer to a larger problem. All insight is welcome and feel free to correct me if I've made any incorrect statements/assumptions!