Solved

Convert from String to String *

Posted on 2004-04-25
3
205 Views
Last Modified: 2010-04-01
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
Comment
Question by:lordiano
  • 2
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 10915581
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
 
LVL 12

Accepted Solution

by:
stefan73 earned 125 total points
ID: 10916262
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
 
LVL 12

Expert Comment

by:stefan73
ID: 10916271
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now