Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. func(void) or func() ?

func(void) or func() ?

Scheduled Pinned Locked Moved The Lounge
questioncsharpvisual-studio
26 Posts 14 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use void for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits to void? What do you prefer for your member functions: void SomeFunc(void); or void SomeFunc();


    When I am king, you will be first against the wall.

    M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #17

    in C#, void SomeFunc(void) is not a legal syntax. A parameterless function must be declared void SomeFunc(). It drives me crazy, especially because I like the first way to explicitly say "this function takes no parameters". Oh well. Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

    A 1 Reply Last reply
    0
    • M Marc Clifton

      in C#, void SomeFunc(void) is not a legal syntax. A parameterless function must be declared void SomeFunc(). It drives me crazy, especially because I like the first way to explicitly say "this function takes no parameters". Oh well. Marc Help! I'm an AI running around in someone's f*cked up universe simulator.

      A Offline
      A Offline
      Anna
      wrote on last edited by
      #18

      Me too. X| Anna :rose: "Be yourself - not what others think you should be"
      - Marcia Graesch

      1 Reply Last reply
      0
      • J jan larsen

        Stroustrup had an article in CUJ a couple of months ago on the subject "C and C++ compatibility", he mentions the empty parameter list vs. the void parameter list and one of them is supposed to mean that the function may take a parameter of any type, but I can't remember which... "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus

        D Offline
        D Offline
        David Salter
        wrote on last edited by
        #19

        jan larsen wrote: one of them is supposed to mean that the function may take a parameter of any type, but I can't remember which... See my post above. Dave.

        1 Reply Last reply
        0
        • L Lost User

          Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use void for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits to void? What do you prefer for your member functions: void SomeFunc(void); or void SomeFunc();


          When I am king, you will be first against the wall.

          T Offline
          T Offline
          Tim Smith
          wrote on last edited by
          #20

          From the C++ standard: If the parameterdeclarationclause is empty, the function takes no arguments. The parameter list (void) is equivalent to the empty parameter list. Tim Smith I'm going to patent thought. I have yet to see any prior art.

          T 1 Reply Last reply
          0
          • T Tim Smith

            From the C++ standard: If the parameterdeclarationclause is empty, the function takes no arguments. The parameter list (void) is equivalent to the empty parameter list. Tim Smith I'm going to patent thought. I have yet to see any prior art.

            T Offline
            T Offline
            Tim Smith
            wrote on last edited by
            #21

            Note: void Func (); Means two different things to C and C++ Tim Smith I'm going to patent thought. I have yet to see any prior art.

            1 Reply Last reply
            0
            • V Vagif Abilov

              main function can be declared as returning void or int both in C and C++. If you declare it as int, you let your program return a value (typically an error code) that operating system or calling process can use. Vagif Abilov MCP (Visual C++) Oslo, Norway Hex is for sissies. Real men use binary. And the most hardcore types use only zeros - uppercase zeros and lowercase zeros. Tomasz Sowinski

              E Offline
              E Offline
              Eddie Velasquez
              wrote on last edited by
              #22

              Vagif Abilov wrote: main function can be declared as returning void or int both in C and C++ Returning void is not standard C++. The standard C++ version of main is

              int main()
              {
              }


              There are only 10 kind of people in the world: those who understand binary and those who don't.

              1 Reply Last reply
              0
              • L Lost User

                Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use void for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits to void? What do you prefer for your member functions: void SomeFunc(void); or void SomeFunc();


                When I am king, you will be first against the wall.

                M Offline
                M Offline
                Maximilien
                wrote on last edited by
                #23

                I don't care, I decided to use only the following prototype for all of my C functions, and use casting till death!

                void someFunc( const void * const * const args )
                {

                }

                and deal with it later ! Max.

                A 1 Reply Last reply
                0
                • L Lost User

                  Since upgrading to VS.NET I have noticed that any classes I add using the "Add New Class" wizard will use void for functions with no params (such as constructors/destructors). Personally, I haven't bothered doing this sonce my C days, so my question is - are there any benefits to void? What do you prefer for your member functions: void SomeFunc(void); or void SomeFunc();


                  When I am king, you will be first against the wall.

                  E Offline
                  E Offline
                  Eddie Velasquez
                  wrote on last edited by
                  #24

                  Robert Edward Caldecott wrote: void SomeFunc(void); This isn't C++ style it's C style


                  There are only 10 kind of people in the world: those who understand binary and those who don't.

                  1 Reply Last reply
                  0
                  • M Maximilien

                    I don't care, I decided to use only the following prototype for all of my C functions, and use casting till death!

                    void someFunc( const void * const * const args )
                    {

                    }

                    and deal with it later ! Max.

                    A Offline
                    A Offline
                    Alvaro Mendez
                    wrote on last edited by
                    #25

                    :-) Well good for you! But shouldn't you be returning void*? Regards, Alvaro


                    Well done is better than well said. -- Benjamin Franklin

                    1 Reply Last reply
                    0
                    • J jan larsen

                      Stroustrup had an article in CUJ a couple of months ago on the subject "C and C++ compatibility", he mentions the empty parameter list vs. the void parameter list and one of them is supposed to mean that the function may take a parameter of any type, but I can't remember which... "After all it's just text at the end of the day. - Colin Davies "For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #26

                      I have that issue, I may pull it out. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups