Welcome! Log In Create A New Profile

Advanced

Global constants in functions

Posted by Brendonw 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Global constants in functions
May 08, 2006 12:23PM
Hi All

Maybe one of you know what the value or the status is of a globally declared constant inside a function. When the function is called and during the time when the function is not called.

Thanx
Brendon
Mel
Re: Global constants in functions
May 08, 2006 01:57PM
A globally declared constant retains the same value when a function is called and when it is not called. It is always available and never changes.

Hope this helps!
Mel
Re: Global constants in functions
May 08, 2006 02:17PM
Thanx Mel, now I can submit my Assignment.
Re: Global constants in functions
May 11, 2006 05:08PM
Be careful of this one. Are you declaring a global variable (i.e. outside of a function and availible to all functions) or are you declaring a constant variable within a function. Your question is a little ambiguous.

The only time a const or any other variable will take on (wwhat seems to be) global properties is if it is declared within main(). Then obviously any functions within the the same class, or within the scope of main will have access to this variable.

In short, declaring a variable as const does not automatically make it global.
Re: Global constants in functions
May 11, 2006 05:11PM
I did not conclude in my last msg that for a variable to be global (whether const or not) it would have to be declared outside of any function.
Re: Global constants in functions
May 12, 2006 08:16AM
AndreB

Thanx for your input, but I know what a global const or variable or where either should be declared be and is. In question 1 Ass 2 TRACE TABLE. They had a code where they declared a global constant a and we had to trace the value of const a in 2 functions. My question was what is the value while the function is executed and while the function is not called. Does the value of global constants still exist or what within a function even if the function is not called and how do you indicate this on a trace table, Mel my good friend pointed out to me correctly that it does not.
Re: Global constants in functions
May 12, 2006 11:00AM
Ok Brendonw
It appears that I misread your original question. No harm / insult intended.
Re: Global constants in functions
May 12, 2006 11:02AM
No prob. Goodluck with your studies.
Re: Global constants in functions
May 12, 2006 11:06AM
Thanks - to you as well.
Sorry, only registered users may post in this forum.

Click here to login