[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

const pass by reference

Posted on 2002-04-25
3
Medium Priority
?
480 Views
Last Modified: 2012-05-04
Hi

how is it possible to pass a paramter to a function as a const reference.

In C it would look something like this

void Proc(const int &i)
{}

Please don't tell me this is one of the rare cases where C is outrunning Delphi
0
Comment
Question by:koger
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 6970059
you can do it
for instance you can have :

procedure Proc(const I: Integer);

or

procedure DoStuff(const List: TList);

you can do anything with List except assign another value to it
so you can do:
List.Capacity:=x;

but you can't do:
List:=TList.Create;
or
List:=SomeOtherList;
0
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 450 total points
ID: 6970444
const Parameter in Delphi uses call by reference automatically if the variable is bigger than 4 Bytes.
0
 
LVL 3

Expert Comment

by:rondi
ID: 6970610
The const reserved word in method parameters means the compiler should not create a local copy of the parameter, coz the parameter won't be modified.

If you wanna pass stuff by reference, i.e pointing to the
actual variable you'd use the var specifier.

eg.
procedure Proc(var I: Integer);

Although there's no real gain here coz you're still
passing 32 bits.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question