Solved

return a CStringList

Posted on 1998-04-03
1
959 Views
Last Modified: 2013-11-20
My program is as follows:
CStringList CMyClass::Func() const
{
      CStringList aStringList;
                  CString aString = "Hello";
                  aStringList.AddTail(aString);
                  return aStringList;
}

But the following error occured:
error C2664: 'CStringList::CStringList' : cannot convert parameter 1 from 'class CStringList' to 'int'

why? Can I return a CStringList? Thank you very much!
0
Comment
Question by:syyung6
1 Comment
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 100 total points
Comment Utility
No, the CStringList does not have a copy constructor so you can not return a copy from the function. You need to pass in a reference to the list you want to manipulate to the function:

void CMyClass::Func(CStringList& aStringList) const
{
  aStringList.AddTail("Hello");
}


0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video discusses moving either the default database or any database to a new volume.

771 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