Click here to Skip to main content
15,888,136 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: I know absolutely nothing...help, please. Pin
Alan Chambers3-Feb-04 7:39
Alan Chambers3-Feb-04 7:39 
GeneralRe: I know absolutely nothing...help, please. Pin
Anonymous2-Feb-04 4:00
Anonymous2-Feb-04 4:00 
GeneralRe: I know absolutely nothing...help, please. Pin
_Sephiroth_2-Feb-04 10:02
_Sephiroth_2-Feb-04 10:02 
GeneralRe: I know absolutely nothing...help, please. Pin
Roger Wright2-Feb-04 4:51
professionalRoger Wright2-Feb-04 4:51 
GeneralGroup several pages or child windows in to one project Pin
swarnamanoo1-Feb-04 17:44
swarnamanoo1-Feb-04 17:44 
GeneralPerformance problem of using listctrl to retrieve data using ADO in VC++ Pin
Dababa1-Feb-04 17:15
Dababa1-Feb-04 17:15 
GeneralRe: Performance problem of retrieve data using ADO in VC++ Pin
Dababa1-Feb-04 17:43
Dababa1-Feb-04 17:43 
GeneralMoving from MFC CList to stl::vector; please help Pin
Cloaca1-Feb-04 17:14
Cloaca1-Feb-04 17:14 
Hi there everyone,

I'll try to be brief in describing my difficulty.
I have been given good advice from this forum that it would be good to learn how to use the STL instead of always using MFC collections like CList. I have been convinced; seeing how many useful tools are available (I'm going to be using stable_sort for example). Here is the deal. My App has a class (CMyDBM) that had as a member a CList as follows:
CList<CPlayerRec*, CPlayerRec*> m_PlayerList;
Where CPlayerRec is a class that itself holds a fixed number of CStrings and some ints (it has no other classes or structs and nothing dynamic, just some CStrings and ints).
I then had a series of functions in CMyDBM that did various things. Among them was the copy constructor function. The project compiled fine at that point.
I then removed the CList member from CMyDMB and subsituted the following member:
std::vector<CPlayerRec*> m_Players;

I changed the copy constructor to the following:
CMyDBM::CMyDBM(const CMyDBM& initDBM)
{
    CPlayerRec* ptrPlayerRec = NULL;
	
    //****The following line is number 64 in the file (where the error is).
    std::vector<CPlayerRec*>::iterator it = initDBM.m_Players.begin();

    for(/*init is above*/ ; it != initDBM.m_Players.end(); it++)
    {
        ptrPlayerRec = new CPlayerRec;
        *ptrPlayerRec = *((CPlayerRec*)(*it));
        m_Players.push_back(ptrPlayerRec);		
    }
}

Now, when I try to build, I get the following error:
E:\Program Files\Microsoft Visual Studio\MyProjects\Stats\MyDBM.cpp(64) : error C2440: 'initializing' : cannot convert from 'class CPlayerRec *const * ' to 'class CPlayerRec ** '
Conversion loses qualifiers

My idea was to store in the vector a collection of CPlayerRec pointers that I could 'new' as I needed them and then access and delete them later. I am open to storing actual CPlayerRec objects; but then how can I create them 'on the fly' with new and then add them to the vector? I would also have to figure out where / how to delete them.

I appreciate you reading this lengthy post and offering any advice.
Thanks,
Eric
GeneralRe: Moving from MFC CList to stl::vector; please help Pin
Cloaca1-Feb-04 18:02
Cloaca1-Feb-04 18:02 
GeneralRe: Moving from MFC CList to stl::vector; please help Pin
Diddy1-Feb-04 22:21
Diddy1-Feb-04 22:21 
GeneralRe: Moving from MFC CList to stl::vector; please help Pin
Cloaca2-Feb-04 4:49
Cloaca2-Feb-04 4:49 
GeneralRe: Moving from MFC CList to stl::vector; please help Pin
Diddy2-Feb-04 5:41
Diddy2-Feb-04 5:41 
QuestionIs there a function to create sound? Pin
siew hoon1-Feb-04 15:51
siew hoon1-Feb-04 15:51 
AnswerRe: Is there a function to create sound? Pin
Prakash Nadar1-Feb-04 16:26
Prakash Nadar1-Feb-04 16:26 
AnswerRe: Is there a function to create sound? Pin
george ivanov2-Feb-04 2:05
george ivanov2-Feb-04 2:05 
QuestionHow to fix the 2nd dialog from moving? Pin
siew hoon1-Feb-04 15:49
siew hoon1-Feb-04 15:49 
AnswerRe: How to fix the 2nd dialog from moving? Pin
Diddy1-Feb-04 22:40
Diddy1-Feb-04 22:40 
GeneralRe: How to fix the 2nd dialog from moving? Pin
siew hoon21-Feb-04 19:40
siew hoon21-Feb-04 19:40 
GeneralRe: How to fix the 2nd dialog from moving? Pin
Diddy22-Feb-04 10:23
Diddy22-Feb-04 10:23 
GeneralRe: How to fix the 2nd dialog from moving? Pin
Anonymous22-Feb-04 13:33
Anonymous22-Feb-04 13:33 
GeneralRe: How to fix the 2nd dialog from moving? Pin
Diddy23-Feb-04 5:10
Diddy23-Feb-04 5:10 
GeneralRe: How to fix the 2nd dialog from moving? Pin
siew hoon27-Feb-04 16:26
siew hoon27-Feb-04 16:26 
GeneralRe: How to fix the 2nd dialog from moving? Pin
Diddy28-Feb-04 1:21
Diddy28-Feb-04 1:21 
GeneralRe: How to fix the 2nd dialog from moving? Pin
Diddy29-Feb-04 8:52
Diddy29-Feb-04 8:52 
GeneralRe: How to fix the 2nd dialog from moving? Pin
siew hoon2-Mar-04 3:04
siew hoon2-Mar-04 3:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.