--%>

"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 : Explain One Dimensional array One

    One Dimensional array:1) An array is a continuous memory location having similar kind of data in a single row or single column. Declaration in c++ is as under: const int size = 20;int a[size] or int a[2

  • Q : Explain the way to create a Mutex

    Explain the way to create a Mutex.

  • Q : What is SLAM SLAM is a Microsoft

    SLAM is a Microsoft project that blurs the line between static analysis and model checking and deductive reasoning. The main goal of SLAM is to check temporal safety properties of C programs (it actually checks that a program correctly uses the interf

  • Q : Self-created What is the difference

    What is the difference among a self-created certificate, Symbian Signed and a Symbian developer certificate?

  • Q : Define Fetch-execute cycle

    Fetch-execute cycle: The simple set of steps which are endlessly recurring by a computer's Central Processing Unit for each and every program instruction: `Fetch the next instruction suggested by the program counter,' `update the program counter to pa

  • Q : Use Polymorphism Use Polymorphism :

    Use Polymorphism: Programs, especially those converted from non-OOP languages like C, sometimes use state where they should use inheritance. For example,

    Q : Differences between logical and

    What are the differences between logical and physical address spaces?

  • Q : Define Compilation Compilation : It is

    Compilation: It is a process of translating a programming language. This frequently comprises translating a high level programming language into a low level programming language, and the binary form of a specific instruction set. The translation is ex

  • Q : Define the term Catching exceptions

    Catching exceptions: Exceptions are caught in the catch clause of the try statement. Catching an exception provides the program a chance to recover from the trouble or attempt a repair for whatsoever caused it.

  • Q : Define the term Internet Define the

    Define the term Internet: It is a global network of numerous interconnected networks.