Please check my work...

This is a discussion on Please check my work... within the C Programming forums, part of the General Programming Boards category; Hey quzah, I've been reading your post from the previous page about the return statement inside void functions. Well, what ...

  1. #31
    C++ Newbie
    Join Date
    Nov 2005
    Posts
    49
    Hey quzah, I've been reading your post from the previous page about the return statement inside void functions. Well, what if you were to break out of a void function? Shouldn't the return statement be included in all function for the sake of consistency?
    Code:
    void something(int value1, int value2) {
      if(value1 > value2) {
        return;
      }
      std::cout << "The answer is : " << value1 + value2";
      return;
    }
    Then again... I don't like using abort() or exit()...

  2. #32
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You can return early from a void function. It isn't however a requirement. That was the question.


    Quzah.
    Hope is the first step on the road to disappointment.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BN_CLICKED, change button style
    By bennyandthejets in forum Windows Programming
    Replies: 13
    Last Post: 07-05-2010, 11:42 PM
  2. Code doesn't work: Check alphabetical order
    By motozarkov in forum C++ Programming
    Replies: 5
    Last Post: 04-27-2005, 02:53 PM
  3. Shouldn't this code work?
    By DeepFyre in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2004, 01:24 PM
  4. If you are employed as a programmer, please look
    By Flood Fighter in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 09-28-2004, 02:35 AM
  5. writing/reading from file produces double results.
    By stumon in forum C Programming
    Replies: 4
    Last Post: 03-20-2003, 03:01 PM

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