That means that there are no arguments to the function, so the parameter list is void.
Printable View
That means that there are no arguments to the function, so the parameter list is void.
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. :D
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 :D .
This thread is already number 5 for number of replies on the C++ board (as far as I can tell)
Quote:
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?
I came in at 44 - now its 80 :eek: .
Yeah way to go JaWib. We were actually getting somewhere till you posted code. Now on to another tangent.
:D
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...
I could have also done:Quote:
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)
Quote:
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?
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 :p)
Thats what programmings all about ;) Confusion!! Hurray!Quote:
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 :D
Hm maybe this should go to the faq board :DQuote:
We should rename this thread for all the newbies - The complete guide on how to program in C/C++.
Quote:
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!
LOLQuote:
Originally 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 :D
Hm maybe this should go to the faq board :D