How to pass a TStringList back by reference

Posted on 2009-02-21
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


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

What am i doing wrong?
Question by:Xyptilon2
    LVL 5

    Accepted Solution

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

    LVL 13

    Author Comment

    Thanks, what is the difference between -> and .
    LVL 5

    Expert Comment

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

    class Temp {
       void do() {}

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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
    What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
    The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
    The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now