That means that there are no arguments to the function, so the parameter list is void.
That means that there are no arguments to the function, so the parameter list is void.
Do not make direct eye contact with me.
Hey MrDoomMaster remind all of us here never to write a book about C/C++. We are all over the page here. We've gone from like chapter 22 to chapter 1 to chapter 5.
void
- Means that the function does not return any value
- Can also mean that no parameters are passed to a function
- Basically means no data type
And I'm sure my pals will add to the list.
Thats why 5+ people never gang up to write a C++ book, bubba .
Do not make direct eye contact with me.
This thread is already number 5 for number of replies on the C++ board (as far as I can tell)
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Originally posted by JaWiB
Maybe some code will clear things up:
Code:#include <iostream> using namespace std; int Global=0; int Func1() { int a=1; int b=2; return a+b; } //a,b now gone int Func2() { return Global++; //can be changed and accessed since it is global } int Func3(int val) { Global=val; return Global; } int Func4(int& val) { val=10; return val; } int main() { int MainVar=25; int MainVar2=20; cout<<Func1()<<endl;//outputs 3 cout<<Func2()<<endl;//outputs 0, Global now 1 cout<<Global<<endl;//outputs 1; cout<<Func3(MainVar)<<endl;//outputs 25, Global now 25 cout<<Global<<endl;//outputs 25 cout<<Func4(MainVar)<<endl;//outputs 10, MainVar now 10 cout<<MainVar<<endl;//outputs 10 //note MainVar could not be changed without passing it as //a reference, since its scope is within main() }
in your code I saw "int Func4(int& val)"
I thought you put the & in front of the variable to get the address of that variable? Why is it after the type?
--MrDoomMaster
The kind of DooM that makes the MooD
I came in at 44 - now its 80 .
Do not make direct eye contact with me.
Yeah way to go JaWib. We were actually getting somewhere till you posted code. Now on to another tangent.
We should rename this thread for all the newbies - The complete guide on how to program in C/C++.
lol... See why I like this forum so much? people actually TALK!!... in my previous forum I was it, I would be lucky to get 3 replies in 4 years...
--MrDoomMaster
The kind of DooM that makes the MooD
I could have also done:in your code I saw "int Func4(int& val)"
I thought you put the & in front of the variable to get the address of that variable? Why is it after the type?
Clearer?Code:int Func4(int &val) //or int Func4(int & val)
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Originally posted by JaWiB
I could have also done:
Clearer?Code:int Func4(int &val) //or int Func4(int & val)
oh yes, I get it now. It's just the way you form it. Got it!
But see, that's where pointers confuse me. If a variable already has the information... why do you have to use a pointer to point to that value that the variable already has? Why not use the variable to get the data, instead of a pointer?
--MrDoomMaster
The kind of DooM that makes the MooD
Well what we like to see are people who are not afraid to learn, not afraid to make mistakes (as you've seen by my posts), and not afraid to listen.
If you post with the right attitude...this is the end result - a huge thread where everyone wants to help. It is a great place to be here on the board.
Now where were we with the programming?
The & can be put in any of these ways correctly:
int &x
int & x
int& x
int & x
Get it ? (Thanks a lot Jawib )
Do not make direct eye contact with me.
Thats what programmings all about Confusion!! Hurray!Yeah way to go JaWib. We were actually getting somewhere till you posted code. Now on to another tangent.
At some point though, DoomMaster, you're going to have to write some code for yourself....then you'll understand
Hm maybe this should go to the faq boardWe should rename this thread for all the newbies - The complete guide on how to program in C/C++.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared
Originally posted by Bubba
Well what we like to see are people who are not afraid to learn, not afraid to make mistakes (as you've seen by my posts), and not afraid to listen.
If you post with the right attitude...this is the end result - a huge thread where everyone wants to help. It is a great place to be here on the board.
Now where were we with the programming?
I would hit the people that say a "bubba" is some fat scary gay dude in jail waiting for newcomers... absolute nonsense!
Bubba actually tends to be an experienced programmer... not a fat guy in a jail cell!
--MrDoomMaster
The kind of DooM that makes the MooD
LOLOriginally posted by JaWiB
Thats what programmings all about Confusion!! Hurray!
At some point though, DoomMaster, you're going to have to write some code for yourself....then you'll understand
Hm maybe this should go to the faq board
--MrDoomMaster
The kind of DooM that makes the MooD