I have some code which looks like the following:
How do I port to c++?Code:void x(int a) { do something with a } void y(int b) { return x(50); }
Regards
/RP
I have some code which looks like the following:
How do I port to c++?Code:void x(int a) { do something with a } void y(int b) { return x(50); }
Regards
/RP
Wait, I'm not allowed to use void functions in C++? Oh no my life, ruined!
ROFLOriginally Posted by Tonto
![]()
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
Funny guy ey.....I urgently need help on this.
So don't laugh about silly stuff, give some help instead.
And if your'e so geeky that you can't find anything else to laugh about get a life.
I'm just curious if this is the same thing as doing:
Regards,Code:void x(int a) { do some stuff.... } void y(int b) { x(50); }
/RP
In regards to your original question:
Let's see, I build the project and woops!Code:///////// // Test suite ////////// void x(int a) { a += 50; } void y(int b) { return x(50); } int main(int argc, char* argv[]) { y(10); }
Yeah, you can't return a value, it's a void function specifying it won't return a value. However, from your updated post:Originally Posted by VC6.0++
Works fine. No errors there. Here's a short thing about functional programming and void: http://www.mtsu.edu/~csci117/manual/lab8/lab8.html and another small reference: http://www.fredosaurus.com/notes-cpp...uncstruct.html and all of this is perfectly acceptable in both C and C++. We're just elitist ..........es around here, sorry. A quick google search on void functions does solve our issue quite nicely however!Code:///////// // Test suite ////////// void x(int a) { a += 50; } void y(int b) { x(50); } int main(int argc, char* argv[]) { y(10); return 0; }
Mate I'm a self confessed geek. Read the sig.Originally Posted by seizmic
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
>> could I just replace the return x(50) with x(50) and that will do the same?
The same? No of course not. Then you are not returning a value anymore. But seeing as you can't do that kind of stuff in 'void' functions in the first place, it doesn't matter. So you could say yes it is the same, but I mean, all it seems you want to do is call the function, you can not return a value. That's just how void functions work, and why they exist. Also try reading the articles I provided in my above post. I picked them out because I felt they would answer many of the questions you might have, including the one you just asked. You also might like reading this more general howstuffworks article on C functions:
http://computer.howstuffworks.com/c12.htm
It does a good job at bringing the this important concept of programming down to basic terms, including 'void' functions.
so it true, you can be a dumbass and still program. sighOriginally Posted by ahluka
Originally Posted by ILoveVectors
Yep.
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
yes but this is why I ask....it's a c snippet which I would like to port to c++
could I just replace the return x(50) with x(50) and that will do the same?
are you like not very bright or?
Oh god not again... started an 'argument' with someone possessing the mental intelligence of a 12 year old![]()
I'm going to be a good boy this time mods![]()
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
seems like ahluka has to much time on his hands.....why not do something constructive with it...like go dr_wn himself or something like that
Amateur remarks
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.
- Mike McShaffry
The thought of low level programming excites me. <- hmmm I wonder if you even know what low level is