|
|
| Author |
Message |
BlingBling
Toomuchtimeonhands

Joined: 20 Dec 2002 Posts: 944
|
Posted: 03/17/03 - 01:05 Post subject: C++ a few questions
|
|
|
Your program will set the values of the density and viscosity of water, using a const statement
First question.................What is a const statement?
should this be just like
float(density &, viscos&)
{
float density=.0625;
float viscos="value";
}
next what does something mean by call by value and call be reference? can someone please expain what that means.
Thanks,
Matt
|
|
|
Back to top
|
|
|
|
 |
Jedite
Luke Warm

Joined: 16 Oct 2002 Posts: 123
|
Posted: 03/17/03 - 09:17 Post subject:
|
|
|
Constant means a variable that will not change.. Some functions in C++ need constant variables to be able to use them....
so probably set
const float density = 0.0625f;
fyi the f at the end is to explicitly say its a float and not a double.
calling by value or sending a variable by value is that for instance you have variable test in ur main loop......... and call it in a function like so
void main(void)
{
int test = 10;
trashfunction(test);
trash2function(&test);
}
in the first trash function i am sending it by value .... so the function is getting a copy of the variable what ever changes are made to that variable in the function wont be reflected in the variable test.
the sencond trash function i am sending the variable by reference... this means that i am passing a "reference of the variable" you catch it and you will have direct access to all the values that variable contains and you any changes made in the function will be reflected in the variable.
|
|
|
Back to top
|
|
|
|
 |
BlingBling
Toomuchtimeonhands

Joined: 20 Dec 2002 Posts: 944
|
Posted: 03/17/03 - 10:03 Post subject:
|
|
|
|
ah ok badass. One more question.......I dont understand the void stuff.. what does that represent and why do we put it?
|
|
|
Back to top
|
|
|
|
 |
Jedite
Luke Warm

Joined: 16 Oct 2002 Posts: 123
|
Posted: 03/17/03 - 10:08 Post subject:
|
|
|
void trash(void)
this means that the function will not be returning anything and that the function does not take any values.... so we use void to represent that...
in the future of your class im guessing you will discuss void pointers... which is very different....
btw were are u taking class?
|
|
|
Back to top
|
|
|
|
 |
|
|