Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 131,567 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,171 people online right now. Registration is fast and FREE... Join Now!




VERY quick question, alternative to void function

 
Reply to this topicStart new topic

VERY quick question, alternative to void function

jayhuang
post 11 Oct, 2006 - 03:03 PM
Post #1


New D.I.C Head

*
Joined: 11 Oct, 2006
Posts: 31


My Contributions


I looked over other forums and couldn't find the answer to this. C++ defines a void type for functions, which denotes no return value. If this was not available, what alternatives could be used?
User is offlineProfile CardPM

Go to the top of the page


Amadeus
post 11 Oct, 2006 - 03:15 PM
Post #2


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,158



Thanked 31 times

Dream Kudos: 25
My Contributions


You could return a value.
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 11 Oct, 2006 - 04:27 PM
Post #3


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


well you can always return a bool which is 1 bit so itll be best alternative to void.
im pretty sure there isnt anything else like void.
User is offlineProfile CardPM

Go to the top of the page

jayhuang
post 11 Oct, 2006 - 04:56 PM
Post #4


New D.I.C Head

*
Joined: 11 Oct, 2006
Posts: 31


My Contributions


Thank you very much Mrafcho001. That should be the only alternative to void.
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 12 Oct, 2006 - 02:02 AM
Post #5


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,895



Thanked 34 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


Actually, even when you mention void, internally the function main() does return a value to it's calling function 'start()' (In Windows)
The value of the EAX register is set to zero before main() exits.
This return value is used to decide how the program terminates.

So even returning zero from main() is an equivalent of returning nothing using void.
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 12 Oct, 2006 - 12:52 PM
Post #6


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


Interesting B2C...

but im pretty sure he wasnt asking about main.
User is offlineProfile CardPM

Go to the top of the page

born2c0de
post 13 Oct, 2006 - 09:49 AM
Post #7


printf("I'm a %XR",195936478);

Group Icon
Joined: 26 Nov, 2004
Posts: 3,895



Thanked 34 times

Dream Kudos: 2800

Expert In: 80x86 Assembly, C/C++, VB6, VB.NET, C#, J2SE, Win32 API, Reversing

My Contributions


QUOTE
but im pretty sure he wasnt asking about main.

Actually, since the EAX register is almost always used to return values from all functions, my statement is valid for almost all functions.
User is offlineProfile CardPM

Go to the top of the page

jayhuang
post 13 Oct, 2006 - 01:27 PM
Post #8


New D.I.C Head

*
Joined: 11 Oct, 2006
Posts: 31


My Contributions


Thanks B2C. I didn't notice that for main().
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 03:02AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month