How far should I go?

This is a discussion on How far should I go? within the C++ Programming forums, part of the General Programming Boards category; Recently I started learning C++ and so far I like what I get (always programmed in C before). I have ...

  1. #1
    return 0;
    Join Date
    Jan 2005
    Location
    Netherlands
    Posts
    89

    How far should I go?

    Recently I started learning C++ and so far I like what I get (always programmed in C before). I have a question concerning classes, though not really a coding problem.

    I'm creating a class that'll handle my OpenGL window. My question is: should I be creating functions that simply call a win32 api function with only one extra argument (most of the time the window handle). Here's an example:

    One of the member functions is GetHandle(), which returns the window handle. Now for moving the window, I could create my own function:

    Code:
    void GLWindow::SetPos(int x, int y)
    {
        SetWindowPos(this->handle, HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
    }
    but instead of using my own SetPos() function, I could also simply do this:

    Code:
    SetWindowPos(object.GetHandle(), HWND_TOP, x, y, 0, 0, SWP_NOSIZE);
    So are there advantages if I create my own member function, or is that useless?
    Last edited by Snip; 02-01-2006 at 07:31 AM.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    So are there advantages if I create my own member function
    Yes, the member function is easy to read, which makes what it does easy to understand, and the member function hides the complexity of what you are doing, i.e. dealing with the hieroglyphic-esque win32 api.
    Last edited by 7stud; 02-01-2006 at 07:50 AM.

Popular pages Recent additions subscribe to a feed

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