Click here to Skip to main content
15,909,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to set CDialog size in pixels ? Pin
vgrigor28-Jan-04 23:50
vgrigor28-Jan-04 23:50 
AnswerRe: How to set CDialog size in pixels ? Pin
Iain Clarke, Warrior Programmer29-Jan-04 6:11
Iain Clarke, Warrior Programmer29-Jan-04 6:11 
Generalto retrieve the address line from explorer Pin
sinuommen28-Jan-04 23:47
sinuommen28-Jan-04 23:47 
GeneralRe: to retrieve the address line from explorer Pin
Mukkie29-Jan-04 11:25
Mukkie29-Jan-04 11:25 
GeneralRe: to retrieve the address line from explorer Pin
sinuommen29-Jan-04 17:02
sinuommen29-Jan-04 17:02 
GeneralRe: to retrieve the address line from explorer Pin
Mukkie30-Jan-04 23:34
Mukkie30-Jan-04 23:34 
Questiondoubt in STL - MAP??? Pin
Ilamparithi28-Jan-04 23:38
Ilamparithi28-Jan-04 23:38 
GeneralRetrieving a pointer to an item in a std::list Pin
bneacetp28-Jan-04 23:36
bneacetp28-Jan-04 23:36 
I have a std::list of objects and want to capture the object by reference by storing its address in a pointer to use it in other code. I am having problems pulling the object's address from the iterator. The sample code below shows what I am doing.

// A list of MyObject instances
typedef list<MyObject> ObjList;

int main()
{
    ObjList obList;
    MyObject* pObj = 0;

    for(int i = 0; i < 10; ++i)
    {
        pObj = new MyObject(i);
        obList.push_back(*pObj);
    }
    pObj = 0;

    ObjList::iterator it = obList.begin();
    for(int i = 0; i < 3; ++i)    
        ++it;   // increment the iterator

    MyObject *pMy3rdObject = it;    <<<<<---C2440 ERROR HERE

    [work done with pMy3rdObject here]

    return 0;
}


When I compile the code above, I get the following error:
error C2440: 'initializing' : cannot convert from 'std::allocator<_Ty>::value_type' to 'MyObject *'
with
[
_Ty=MyObject
]

Any ideas of how to successfully and safely do this?

Thanks in advance! Smile | :)

Happy Programming!

WWW::CodeProject::BNEACETP
GeneralRe: Retrieving a pointer to an item in a std::list Pin
bneacetp28-Jan-04 23:57
bneacetp28-Jan-04 23:57 
GeneralGUI tools Pin
louis28-Jan-04 23:31
louis28-Jan-04 23:31 
GeneralURLDownloadToFile IBindStatusCallback And Visual Basic :-( Pin
Braulio Dez28-Jan-04 23:30
Braulio Dez28-Jan-04 23:30 
GeneralRe: URLDownloadToFile IBindStatusCallback And Visual Basic :-( Pin
Daniel Turini29-Jan-04 3:50
Daniel Turini29-Jan-04 3:50 
GeneralRe: URLDownloadToFile IBindStatusCallback And Visual Basic :-( Pin
Braulio Dez29-Jan-04 4:02
Braulio Dez29-Jan-04 4:02 
QuestionCreateDIBSection size limitation? Pin
CodeBrain28-Jan-04 23:18
CodeBrain28-Jan-04 23:18 
GeneralDisplaying 2 dialogs in the same window (URGENT) Pin
ArFuk28-Jan-04 23:18
ArFuk28-Jan-04 23:18 
GeneralRe: Displaying 2 dialogs in the same window (URGENT) Pin
sstoyan29-Jan-04 2:30
sstoyan29-Jan-04 2:30 
QuestionCan I get file path name which is created by Rresourc Editor: Pin
Morris_Pan28-Jan-04 22:56
Morris_Pan28-Jan-04 22:56 
AnswerRe: Can I get file path name which is created by Rresourc Editor: Pin
Steve S28-Jan-04 23:34
Steve S28-Jan-04 23:34 
GeneralRe: Can I get file path name which is created by Rresourc Editor: Pin
Morris_Pan29-Jan-04 3:52
Morris_Pan29-Jan-04 3:52 
QuestionHow to move Bitmap in Dialog ? Pin
Morris_Pan28-Jan-04 22:48
Morris_Pan28-Jan-04 22:48 
AnswerRe: How to move Bitmap in Dialog ? Pin
SJolly29-Jan-04 0:52
SJolly29-Jan-04 0:52 
GeneralRe: How to move Bitmap in Dialog ? Pin
Morris_Pan29-Jan-04 3:39
Morris_Pan29-Jan-04 3:39 
GeneralRe: How to move Bitmap in Dialog ? Pin
Morris_Pan29-Jan-04 15:38
Morris_Pan29-Jan-04 15:38 
GeneralRe: How to move Bitmap in Dialog ? Pin
SJolly29-Jan-04 21:58
SJolly29-Jan-04 21:58 
GeneralUserdefined ToolBar hiding Pin
swarnamanoo28-Jan-04 22:01
swarnamanoo28-Jan-04 22:01 

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.