--%>

"Const" qualifier for pointers and member function

In C++ an arguments to a function can be declared as constant as shown below:

Int strlen (constant char * p);

Int length (constant string & s);

The qualifier const tells the compiler that the function should not modify the arguments. The compiler will produce error when this situation is violated. This type of declaration is significant only when we pass arguments by reference or pointer.

Constant member functions: If a member function does not alter any data in the class, than we have may declare it as a constant member function as follows:

Void mul (int. Int) constant;

Double get _ balance constant;

The qualifier constant is appended to the function proto types (in both declaration and definition). The compiler is as a constant will generate an error message if such functions try to alter the data values.

 

 

 

   Related Questions in Programming Languages

  • Q : Define Zip file Zip file : It is a file

    Zip file: It is a file employed to store compressed versions of the files. In connection with Java bytecode files, such have mostly been superseded by the Java Archive (abbreviated as JAR) files.

  • Q : What is an Import statement Import

    Import statement: A statement which makes the names of one or more interfaces or classes accessible in a different package from the one in which they are stated. Import statements pursue any package declaration {package!declaration}, and precede any i

  • Q : State Null character State Null

    State Null character: The \u0000 character. The care must be taken not to confuse this with null reference.

  • Q : Explain Throw statement Throw statement

    Throw statement: It is a statement employed to throw an exception. For example:     throw new IndexOutOfBoundsException(i+" is too large.");

  • Q : Explain the way to enter element content

    Explain the way to enter element content.

  • Q : Define Daemon thread Daemon thread :

    Daemon thread: The daemon threads are non-user threads. They are usually employed to carry out low-priority tasks which must not take priority over the major task of the program. They can be employed to do helpful work whenever all other user threads

  • Q : Walk through the steps essential to

    How can you walk through the steps essential to parse XML documents?

  • Q : What is the way to use XForms What is

    What is the way to use XForms?

  • Q : Problem on Planar scintigraphy Let

    Let assume seven PMTs situated around the origin of the x-y coordinates on the face of the Anger camera as illustrated in the figure. The size of the PMTs is 2mm by 2 mm and each PMT has been allocated a number. The single scintillation event yields a response from PM

  • Q : Define Thread starvation Thread

    Thread starvation: It is a condition which applies to a thread which is prevented from running by other threads which do not yield or turn into blocked.