How to do this????
-
Hi, i know that i can set each of the incoming parameters of my function to a default value, like this:
void Function(int x , int y = 10);
and then,i can call to the function in 2 ways:
Function(10,20); //x = 10 , y = 20
Function(10); //x = 10 , y = 10my question is - how can i set a CString object to empty by default? for example:
void Function(int x , CString string = ???????);
and call that function:
Function(10,"Not an empty string"); // x = 10 , string = "Not an empty string"
Function(10); // x = 10 , string = string.Empty()anyone????????:doh: Regards, Eli
-
Hi, i know that i can set each of the incoming parameters of my function to a default value, like this:
void Function(int x , int y = 10);
and then,i can call to the function in 2 ways:
Function(10,20); //x = 10 , y = 20
Function(10); //x = 10 , y = 10my question is - how can i set a CString object to empty by default? for example:
void Function(int x , CString string = ???????);
and call that function:
Function(10,"Not an empty string"); // x = 10 , string = "Not an empty string"
Function(10); // x = 10 , string = string.Empty()anyone????????:doh: Regards, Eli
As smple as u set the integer values. void Function( int x , CString string = "" ); Rahim Rattani Software Engineer, Matrix Systems (Pvt) Ltd., Karachi - Pakistan
-
Hi, i know that i can set each of the incoming parameters of my function to a default value, like this:
void Function(int x , int y = 10);
and then,i can call to the function in 2 ways:
Function(10,20); //x = 10 , y = 20
Function(10); //x = 10 , y = 10my question is - how can i set a CString object to empty by default? for example:
void Function(int x , CString string = ???????);
and call that function:
Function(10,"Not an empty string"); // x = 10 , string = "Not an empty string"
Function(10); // x = 10 , string = string.Empty()anyone????????:doh: Regards, Eli
eli15021979 wrote: my question is - how can i set a CString object to empty by default? for example: void Function(int x , CString string = ???????); and call that function: Function(10,"Not an empty string"); // x = 10 , string = "Not an empty string" why don't you do the same as you code with integers...?
void Function(int x , CString string = "");
Then you call it the way you like...
Function(10, "Hello CP"); // Function(10, "")
Function(10); // Function(10, "Hello CP")
TOXCCT >>> GEII power
[toxcct][VisualCalc] -
Hi, i know that i can set each of the incoming parameters of my function to a default value, like this:
void Function(int x , int y = 10);
and then,i can call to the function in 2 ways:
Function(10,20); //x = 10 , y = 20
Function(10); //x = 10 , y = 10my question is - how can i set a CString object to empty by default? for example:
void Function(int x , CString string = ???????);
and call that function:
Function(10,"Not an empty string"); // x = 10 , string = "Not an empty string"
Function(10); // x = 10 , string = string.Empty()anyone????????:doh: Regards, Eli
Also, you need to decide if the function accepting the CString really REQUIRES a CString object. Maybe you can get by with a LPCTSTR instead. Then you can write your function:
void Function(int x , LPCTSTR szString = NULL);
and call that function:Function(10, "Not an empty string"); // x = 10 , szString != NULL Function(10); // x = 10 , szString = NULL
You can get really tweaked after awhile working with code all written to accept a CString by value, and then when you examine the function's use of the string, it could have easily sufficed to send it a string constant instead.