Solved

return a CStringList

Posted on 1998-04-03
1
1,012 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
[X]
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
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
Perl Awk Need Help 3 139
Best tools for Backup and restore of Wordpress site 6 58
isEverywhere  challenge 19 85
Is there a simple front-end menu system. 9 122
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

733 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