Results 1 to 2 of 2

Thread: Calling a virtual function crashed my program

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2001
    Location
    Québec, Canada
    Posts
    131

    Calling a virtual function crashed my program

    Hello,
    I'm actually creating an agenda. To make it easier to update, I created a DLL containing the class CAgenda. Some function of that agenda are virtual, such as the MonthChanged in order that my main application know when the month change. When my main application call SetMonth, it execute and the virtual function execute. But when my CAgenda call SetMonth, the program crashes at the moment it call the virtual function.

    Here my code:
    PHP Code:
    void CAgenda::SetCurrentMonth()
    {
            
    SetMonth(GetCurrentMonth())
    }

    void CAgenda::SetMonth(Month NewMonth)
    {
            
    Month temp NewMonth;
            
    MonthChanged(temp);
            
    m_Month temp;
    }

    void CAgenda::MonthChanged(Month &month)
    {
            return;

    So, I my program call SetMonth, all work, but if it call SetCurrentMonth, my program crash at the moment it call MonthChanged. Someone know why?
    Khavoerm Irithyl

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I think the failure lies somewhere else, not in this part of the code.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width