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.
  • C Christian Graus

    Vagif Abilov wrote: main function can be declared as returning void or int both in C and C++. Wrong. void main is an aberation tolerated by bad compilers such as VC++. Post an example with void main into comp.lang.c++, and watch how many people jump to tell you that is not C++, as defined by the standard, at all. 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

    J Offline
    J Offline
    John Burton
    wrote on last edited by
    #12

    Post almost *anything* into comp.lang.c++ and see how many people jump on your post. I have to say it's the most unhelpful group on usenet. The people there seem to take much more interest in putting people down than it trying to help them.

    L C 2 Replies Last reply
    0
    • J John Burton

      Post almost *anything* into comp.lang.c++ and see how many people jump on your post. I have to say it's the most unhelpful group on usenet. The people there seem to take much more interest in putting people down than it trying to help them.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #13

      Sounds just like 99% of the Linux community! ;)


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

      1 Reply Last reply
      0
      • J John Burton

        Post almost *anything* into comp.lang.c++ and see how many people jump on your post. I have to say it's the most unhelpful group on usenet. The people there seem to take much more interest in putting people down than it trying to help them.

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

        That is probably true, but I suspect it's partly because they are sick of being asked Windows programming questions. Either way, void main is plain wrong, that is all I was trying to say. And while it can be daunting, comp.lang.c++ is a hell of a good place to improve your C++ skills. 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
        • C Christian Graus

          Anna :) wrote: You haven't looked at any of my source then. Fair enough... I knew it could be done that way, you understand, it's just that with all the people I have worked with, all the code I have downloaded and all the books I have read ( including both from Stroustrup ), I've never seen it used. I don't think it's particularly wrong, only void main is actually *wrong*, but I see a fair bit of it, and as I say, no int main(void) 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

          J Offline
          J Offline
          jan larsen
          wrote on last edited by
          #15

          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 C 2 Replies Last reply
          0
          • C Christian Graus

            Anna :) wrote: You haven't looked at any of my source then. Fair enough... I knew it could be done that way, you understand, it's just that with all the people I have worked with, all the code I have downloaded and all the books I have read ( including both from Stroustrup ), I've never seen it used. I don't think it's particularly wrong, only void main is actually *wrong*, but I see a fair bit of it, and as I say, no int main(void) 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

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

            Having never read a C++ book until after I learnt the language :eek: it just made sense to me that if you have to specify that a method returns void, it was more consistant to specify it for methods which take no parameters also. :) As it's not mandated either way by the language spec, it really comes down to personal style. It is notable though that if you try to declare a C# method with parameter "void" the compiler barfs at you..which only goes to reinforce one of your earlier sigs. ;) Anna :rose: "Be yourself - not what others think you should be"
            - Marcia Graesch

            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
              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