Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 C++ Architecture
Index -> Programming, C++ -> C++ Help
Goto page Previous  1, 2
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Clayton




PostPosted: Thu Nov 23, 2006 9:19 pm   Post subject: (No subject)

wtd wrote:

store the square of the first argument in a locally scoped argument called "bar".


I'm sure I know what you meant by this, but do you mean create a local variable to the function foo? (I'm pretty sure thats what you meant, just making sure and clarifying it for Mr.Gruntsworthy just in case Razz)
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Nov 23, 2006 9:37 pm   Post subject: (No subject)

Freakman wrote:
wtd wrote:

store the square of the first argument in a locally scoped argument called "bar".


I'm sure I know what you meant by this, but do you mean create a local variable to the function foo? (I'm pretty sure thats what you meant, just making sure and clarifying it for Mr.Gruntsworthy just in case Razz)


Yes.
Clayton




PostPosted: Thu Nov 23, 2006 10:00 pm   Post subject: (No subject)

Any specific reason we are doing that then? Is this going to be something to be built upon eventually?
wtd




PostPosted: Fri Nov 24, 2006 12:01 am   Post subject: (No subject)

Scope is a very important concept.
Mr. Gruntsworthy




PostPosted: Fri Nov 24, 2006 8:13 am   Post subject: (No subject)

please explain a little further; it's morning and my brain hasn't booted up yet, lol.....
wtd




PostPosted: Fri Nov 24, 2006 6:48 pm   Post subject: (No subject)

You have your function:

code:
int foo(int x, int y)
{
   return ((x * x) * y) + 1
}


I would like you to rewrite this such that the result of:

code:
x * x


is stored in a variable called "bar". This variable must be scoped locally to the function "foo". That is, it should not exist outside of the "foo" function.
Mr. Gruntsworthy




PostPosted: Fri Nov 24, 2006 10:33 pm   Post subject: (No subject)

damnit i hate it when people use such high levels of tech talk and can't use simple english. My brain is on 'safe mode' and has been for the last week.
wtd




PostPosted: Sat Nov 25, 2006 12:11 am   Post subject: (No subject)

Let me demonstrate.

code:
void a()
{
   some_type b = some_value;

   do_something_to(b);
}


Here the variable b is scoped as local to the function a.
Sponsor
Sponsor
Sponsor
sponsor
Mr. Gruntsworthy




PostPosted: Sat Nov 25, 2006 10:54 am   Post subject: (No subject)

I think i see....

I have alot to learn before i start attending the International Academy of Design and Tecnology in July.
wtd




PostPosted: Sat Nov 25, 2006 5:26 pm   Post subject: (No subject)

Mr. Gruntsworthy wrote:
I think i see....

I have alot to learn before i start attending the International Academy of Design and Tecnology in July.


Yes, but you have a fair amount of time. Think of it as a challenge, and you will do well.

What you need to do is write code. Write a lot of code. That doesn't mean it has to be huge programs, but rather lots of small projects.

Submit those small programs for frequent critique. Such critiques can be pretty critical, but that's the point.
Mr. Gruntsworthy




PostPosted: Sun Nov 26, 2006 1:18 pm   Post subject: (No subject)

well, if i find time to submit anything i've written, ill do so.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 2  [ 26 Posts ]
Goto page Previous  1, 2
Jump to:   


Style:  
Search: