Solved

return a CStringList

Posted on 1998-04-03
1
974 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
ID: 1317450
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 408
centeredAverage challenge 8 131
matchUp  challenge 6 53
Thin secure Windows 10 5 75
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

17 Experts available now in Live!

Get 1:1 Help Now