The time now is 07/06/08 - 22:17
Log in: Username: Password:
Search forums for:
  

C++ a few questions

Post new topic   Reply to topic
Author Message
BlingBling
Toomuchtimeonhands
Toomuchtimeonhands


Joined: 20 Dec 2002
Posts: 944



PostPosted: 03/17/03 - 01:05    Post subject: C++ a few questions Reply with quote

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
Luke Warm


Joined: 16 Oct 2002
Posts: 123



PostPosted: 03/17/03 - 09:17    Post subject: Reply with quote

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
Toomuchtimeonhands


Joined: 20 Dec 2002
Posts: 944



PostPosted: 03/17/03 - 10:03    Post subject: Reply with quote

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
Luke Warm


Joined: 16 Oct 2002
Posts: 123



PostPosted: 03/17/03 - 10:08    Post subject: Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1

Related topics:
Final Fantasy XI Crafting questions
Few questions about Second Life
Few questions about Everquest 2 world
World War II questions
Two game questions!
EQ2 questions from an ex player
Laptop questions for gaming.
Warhammer Online Quest questions
LCD montior Response time questions:
Two Questions....
Buying Str pure that has no recovery questions..
Some Anarchy Online missions questions
Barbarian Questions:
A few n00b questions
two warlock questions
Questions
A few questions
AoC pvp questions
questions on paypal an how safe it really is
questions

 





Warning: fopen(/home/sites/realpoor.com/htdocs/test_cache/C___a_few_questions_t7073.html) [function.fopen]: failed to open stream: No such file or directory in /home/sites/realpoor.com/htdocs/includes/page_tail.php on line 171

Warning: fwrite(): supplied argument is not a valid stream resource in /home/sites/realpoor.com/htdocs/includes/page_tail.php on line 172

Warning: fclose(): supplied argument is not a valid stream resource in /home/sites/realpoor.com/htdocs/includes/page_tail.php on line 173