Hi Guys,
What is the advantage of intializing the parameter list of the method, e.g
[CODE=c++]
class ReadFile
{
ReadFile(const char* filename = "Mystuff.tx t")
{
// Function defination goes here
}
// Define the rest of the class here
}
[/CODE]
I am asking this because having that I still have to pass the file name when I instantiate the object of the class ReadFile, otherwise I get an error. However I have seen many people defining their classes like this.
What is the advantage of intializing the parameter list of the method, e.g
[CODE=c++]
class ReadFile
{
ReadFile(const char* filename = "Mystuff.tx t")
{
// Function defination goes here
}
// Define the rest of the class here
}
[/CODE]
I am asking this because having that I still have to pass the file name when I instantiate the object of the class ReadFile, otherwise I get an error. However I have seen many people defining their classes like this.
Comment