|
-
November 15th, 2011, 05:17 AM
#1
'=' operator can not be overloaded
Hello,
I have a string x which is either null or has some value. I have to assign this value to another string y. With normal '=' (y = x) operation, I get an error if string x has null value.
I have to check first with the help of "if" statement
Code:
if(x != "") //or catch exception here
y = x;
I have to apply above code in my program everywhere I try to assign one string value to another string (and have to be careful). I would have preferably overloaded '=' operator, but have just leant that it is not possible to overlaod '='.
Can someone please suggest me another way of doing it?
Regards
Ricky
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|