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

x
?
Solved

How to pass a TStringList back by reference

Posted on 2009-02-21
3
Medium Priority
?
623 Views
Last Modified: 2013-11-17
How do I pass back an object, in this case a TStringList in my own function by reference. I now have:

TStringList *aSTDOUT = new TStringList();
TStringList *aSTDERR = new TStringList();
fExecuteFile("Somefilename", *aSTDOUT, *aSTDERR);

With fExecuteFile being declared with:

bool fExecuteFile2 (AnsiString sCodeFileName, TStringList& aSTDOUT, TStringList& aSTDERR);

But then, inside the function, when i do

aSTDOUT->Clear();

I'm getting "[Pointer to structure required on left side of -> or ->*" messages.

What am i doing wrong?
0
Comment
Question by:Xyptilon2
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
migoEX earned 2000 total points
ID: 23703748
bool fExecuteFile2 (AnsiString sCodeFileName, TStringList& aSTDOUT, TStringList& aSTDERR) {
   aSTDOUT.Clear();
}


0
 
LVL 13

Author Comment

by:Xyptilon2
ID: 23703767
Thanks, what is the difference between -> and .
0
 
LVL 5

Expert Comment

by:migoEX
ID: 23703802
You use "->" when accessing a member via pointer, and "." when using an object "as is" (or by reference, which is the same).

class Temp {
public:
   void do() {}
};

// usage
Temp t1;
Temp &t2 = t1;
Temp *pt = new Temp();

t1.do();
t2.do();
pt->do();


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

834 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