Hi,
Following is the program:
Code:
* Default indent to -1. This value tells the function
to reuse the previous value. */
void iputs(char *str, int indent = -1);
int main()
{
iputs("Hello there", 10);
iputs("This will be indented 10 spaces by default");
iputs("This will be indented 5 spaces", 5);
iputs("This is not indented", 0);
return 0;
}
void iputs(char *str, int indent)
{
//Statement 1
static i = 0; // holds previous indent value //followin line is throwing error
if(indent >= 0)
i = indent;
else // reuse old indent value
indent = i;
for( ; indent; indent--) cout << " ";
cout << str << "\n";
}
1. What does statement 1 mean?
2. How does this program achieve the concept of default argument?
3. It throws compiler error at the above statement 1.
Thanks in advance