1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

MFC interview questions

Discussion in 'MFC' started by coderzone, Apr 14, 2006.

  1. rajeswaridvssnr

    rajeswaridvssnr New Member

    Joined:
    Oct 24, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    Hyderabad
    Given two processes, how can they share memory?

    Processes and thread are very similar but they differ in the way they share their resources. Processes are independent and have its own address space. If two independent processes want to communicate they do this by using the following techniques 1.Message Passing 2.Sockets 3. named pipes
     
  2. rajeswaridvssnr

    rajeswaridvssnr New Member

    Joined:
    Oct 24, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    Hyderabad
    How to restrict only one instance of a class object to be created?

    Create a Named Mutex.
    HANDLE hMutex=CreateMutex(TRUE,_T(“NamedMutex”))
     
  3. rajeswaridvssnr

    rajeswaridvssnr New Member

    Joined:
    Oct 24, 2006
    Messages:
    45
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    Hyderabad
    How do I dynamically change the mainframe menu?

    CMenu newMenu;
    newMenu.LoadMenu (IDR_MENU1);
    AfxGetMainWnd()->SetMenu( &newMenu );
    AfxGetMainWnd()->DrawMenuBar();
    newMenu.Detach ();
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    Re: How to restrict only one instance of a class object to be created?

    And check the Mutex existence for each of your instance launch and dont allow it to launch if it exists.
     
  5. hellokareem

    hellokareem New Member

    Joined:
    Jan 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Re: How to restrict only one instance of a class object to be created?

    This answer is sutable for restrict only one instance of a process,
    if u want make singleton class make custructor as private
     
  6. hellokareem

    hellokareem New Member

    Joined:
    Jan 3, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Re: Given two processes, how can they share memory?

    simple one
    Use memory-mapped files to share data memory between
    processes
     
  7. srivenkateshg

    srivenkateshg New Member

    Joined:
    Jun 2, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Re: What is the difference between ANSI Code and UNICODE ?

    -----------------
    This is exactly true. A small correction in the above would be 'ANSI code represents 8bits( one byte) data where UNICODE represents 16bits (2 bytes) data for supporting universal languages.
     
  8. srivenkateshg

    srivenkateshg New Member

    Joined:
    Jun 2, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Re: Given two processes, how can they share memory?

    to add one more techniques, if it is a windows based application, the simplest one is to use WM_COPYDATA message
     
  9. destiny.city

    destiny.city New Member

    Joined:
    Aug 8, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    If anybody can se me the answers for the questions, it is good start for a beginner like me.
     
  10. destiny.city

    destiny.city New Member

    Joined:
    Aug 8, 2007
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    If somebody can send me the answers for the MFC questions plzzzzzzzzzzzzzzz, i have an interview
     
  11. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,285
    Likes Received:
    364
    Trophy Points:
    83
    All answers are there in the thread itself. Try and read the thread and you will find them.
     
  12. Jegan

    Jegan New Member

    Joined:
    Aug 23, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Project Leader
    Location:
    Bangalore
    1. What is the base class for MFC Framework ?

    CObject is the base class for almost all of the MFC classes.
     
  13. riddhi

    riddhi New Member

    Joined:
    Apr 4, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    C++ Developer
    Location:
    United States
    Re: How to handle RTTI in MFC ?

    RTTI in MFC can be done using RUNTIME_CLASS Macro in conjunction with CObject's IsKindOf member function. The argument to IsKindOf is a CRuntimeClass object, which you can get using the RUNTIME_CLASS macro with the name of the class.
     
  14. riddhi

    riddhi New Member

    Joined:
    Apr 4, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    C++ Developer
    Location:
    United States
    Re: What is a message map, and what is the advantage of a message map over virtual functi

    Message Maps, maps the user action in to the appropriate MFC class functions to handle it. The MFC Class which can handle message should be member of CCmdTarget, (i.e) it should be hierarchically derived from CCmdTarget.

    The BEGIN_MESSAGE_MAP macro at the start of the message map specifies two class names as its arguments:
    BEGIN_MESSAGE_MAP(CMyView, CView)
    The first argument names the class to which the message map belongs. The second argument provides a connection with the immediate base class — CView here — so the framework can search its message map, too.

    The message handlers provided in a base class are thus inherited by the derived class. This is very similar to normal virtual member functions without needing to make all handler member functions virtual which is an advantage since overhead of creating VTable is eliminated.

    If no handler is found in any of the base-class message maps, default processing of the message is performed. If the message is a command, the framework routes it to the next command target. If it is a standard Windows message, the message is passed to the appropriate default window procedure.
     
  15. riddhi

    riddhi New Member

    Joined:
    Apr 4, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    C++ Developer
    Location:
    United States
    Re: How to setup a timer?

    Also overide the OnTimer message to do the handling in your class
     
  16. bhagvat4u

    bhagvat4u New Member

    Joined:
    May 27, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Re: What is the base class for MFC Framework ?

    Why are some classed are not derived from CObject?
     
  17. bhagvat4u

    bhagvat4u New Member

    Joined:
    May 27, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Re: Name the Synchronization objects ?

    Some additin to Que - Why we need 4 types of synchronization objects ? What is the exact diff between these?
     
  18. bhagvat4u

    bhagvat4u New Member

    Joined:
    May 27, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Re: What is CSingleDocTemplate?

    What is the diff between SDI/MDI and Dialog based app? Is Dialog based app support Doc/View Arc?
     
  19. freeray

    freeray New Member

    Joined:
    Jul 5, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Re: How to restrict only one instance of a class object to be created?

    delcare the structure function as private

    create a static instance as private

    a static function return the point to the instance

    like

    class MyClass
    {
    public:
    ~MyClass();

    static MyClass* GetInstance(){static MyClass instance; return &instance}

    private:
    MyClass();

    };
     
  20. ramarao44

    ramarao44 New Member

    Joined:
    Apr 17, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0

Share This Page