Pascal

Moderators: None (Apply to moderate this forum)
Number of threads: 4098
Number of posts: 14002

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

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.