Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

return a CStringList

Posted on 1998-04-03
1
1,001 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 147
iSeries FTP Exit Program 8 146
Expand data scrubbing tool 13 35
Whole sheet autoscrub still needed 19 51
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

856 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