Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4106
Number of posts: 14016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Const parameter Posted by TheEvan on 22 Sept 2012 at 6:06 AM
The Const parameter is said to be able to prevent modification of the argument value, but i am able to reassign A as seen below perfectly? So what's the difference between a Const parameter and the default parameter? (other than it working as pointer and hence saving memory for large arguments)
procedure Example(Const A: Integer);
begin
  A:=5;
end;   

Report
Re: Const parameter Posted by DWDuck on 31 Oct 2012 at 2:59 AM
U will not be able to change the value of the const variable again...

Const declaration takes the assigned value of it the first time a value is assigned...

I've never seen a declaration like urs frankly dont know the need of it, but if you do declare a const variable at outside of the procedure variable inputs you cannot change the value... Frankly im surprised your declaration worked...

Hey enjoy
Darkwing Duck aka DWduck signing off :)



 

Recent Jobs