C++ code I can't recognize??

This is a discussion on C++ code I can't recognize?? within the Windows Programming forums, part of the Platform Specific Boards category; OK, This is a class from some MFC code I typed in from my book I'm studying. I understand the ...

  1. #1
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22

    Question C++ code I can't recognize??

    OK,
    This is a class from some MFC code I typed in from my book I'm studying.
    I understand the CFourierDataDialog is deriving from CDialog.
    I understand that the function is inheariting from the CDialog function but only using 1 of the two parameters while the other parameter is being set directly (strange to me cause their inhereting, not calling?!?!? Beats me!)
    But the part that really has me stumped is the { } on the next line?! All I can figure is that it's an empty function, but thought I would run it by the pros and see for sure.

    As usual, your generous assitance would be greatly appreciated.

    Thanks!

    Code:
    class CFourierDataDialog : public CDialog
    {
    public:
    	CFourierDataDialog(CWnd* pParentWnd=NULL) : CDialog("FourierData",pParentWnd)
    	{ }
    	virtual void OnOK();
    };
    Last edited by Guardian; 04-28-2002 at 01:47 AM.
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    It's a constructor. The body is empty because it's using an initialiser list to initialise the class members which, as your favourite C++ text should explain, is more efficient.

  3. #3
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22
    Sorensen,
    Thanks for the response!
    I'm beginning to think your the only guy here who answers these things...

    Anyway, as you where quick to spot, my book was great at getting me started in C and C++ in windows but in the last 3 chapters has quickly outlived it's usefulness. It was giving an introduction to MFC after having only spent 2 chapters Prodecural windows programming and the intro was less then informative. It hadn't even mentioned the CDocument or CWndView classes (which I have JUST learned about ). It just tossed everything into the CMainWnd::OnPaint() function and left it at that. Needless to say, it also never mentioned CArchive and has no intention to.

    So I have jumped into "Special Edition - Using MFC". I'm learning a lot from this one on MFC.

    As for the line of code I couldn't understand, I gather that the CFourierDataDialog function winds up being a copy of the CDialog function with the first parameter "etched in stone" as it where.

    Would this be an accurate assesment or am I right off my rocker here?
    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

  4. #4
    It's full of stars adrianxw's Avatar
    Join Date
    Aug 2001
    Posts
    4,831
    One of the constructors for the CDialog class takes two parameters, you are inheriting from the CDialog class, and calling the base class constructor with the first parameter supplied by your derived class, so in essence, yes, your call to the CFourierDataDialog() constructor will call the CDialog constructor with the first parameter "etched in stone".
    Wave upon wave of demented avengers march cheerfully out of obscurity unto the dream.

  5. #5
    Assembler + Basic from 79
    Join Date
    Apr 2002
    Location
    Canada
    Posts
    22
    That actually makes a lot of sense. Thanks for the explanation!

    Twin engine aircraft are way better. If one engine quits the other takes you to the scene of the crash.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 08:34 AM
  2. Values changing without reason?
    By subtled in forum C Programming
    Replies: 2
    Last Post: 04-19-2007, 11:20 AM
  3. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21