Convert from String to String *

Is there a way to convert a String to a String *?
say a function :
String A_func();

I want to convert whatever returned by A_func to a String* (in VC++.net format)
lordianoAsked:
Who is Participating?
 
stefan73Commented:
Hi lordiano,
If it is your own function which needs a string*, rewrite it to string&. Pointers are evil :-)

Otherwise, you need a temporary var:
string temp=A_func();
call_other_func(&temp); // -> string*


Cheers,
Stefan
0
 
AlexFMCommented:
You need to provide more details. I don't think it is possible to write function like

String A_func();

Compiler doesn't allow this for reference types.
0
 
stefan73Commented:
BTW: Since string& and string* are very closely related, you could also try if an implicit typecast is done when you do

string* A_func();

...but I'm not sure.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.