CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Question Quick parameters question

    I once learned that the point of parameters is so you can pass different values to a function() every time you call it. Because the parameters of functions such as winmain() and wndproc() are not used to do that, are they some sort of special parameters?

  2. #2
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Quick parameters question

    I don't get what you mean by your question. Of course they do get parameters (see http://msdn.microsoft.com/en-us/libr...59(VS.85).aspx and http://msdn.microsoft.com/en-us/libr...73(VS.85).aspx). The only thing I can see that's special about them is that the're callbacks, i.e. not you call them, but instead you define them and Windows calls them.

    Ah, and... Welcome to CodeGuru!
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  3. #3
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: Quick parameters question

    Thanks

    Hmmm, ok, let me ask a different question.

    Seeing as parameters are used to pass different values to a function() every time you call it, do ALL function parameters get passed to the function, even functions like winmain()?

    Do you know what i mean.

  4. #4
    Join Date
    Jun 2010
    Location
    Germany
    Posts
    2,675

    Re: Quick parameters question

    Yes, in C++ (and we are in a C++ forum here), always all parameters are passed. They may, however, have values that actually mean "nothing" like the NULL passed as hPrevInstance to WinMain(). But that does not necessarily mean that all parameters need to be specified when you call the function: Functions can have parameters with default values, like e.g. all the parameters of the CFileDialog constructor except the first one. Parameters with default values that are omitted when you write the function call are implicitly passed by the compiler for you, so that the function always ends up getting all its parameters.

    In C (and that includes some library functions that may be called from a C++ program as well), however, this is another story: Some functions may indeed be called with more or less parameters. But as this isn't really C++ I'll leave it out here for brevity.

    And there's also function overloading (a C++ concept, to clarify) that may result in various equally named functions with differing numbers of parameters. But every one of these individual functions is always called with all its respective parameters so this is no exception to the above.
    I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.

    This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.

  5. #5
    Join Date
    Feb 2011
    Location
    UK
    Posts
    73

    Re: Quick parameters question

    Thanks

Tags for this Thread

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

Featured