[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

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)
0
lordiano
Asked:
lordiano
  • 2
1 Solution
 
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:
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
 
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

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now