--%>

"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 in process verses out of

    Explain in process verses out of process component.

  • Q : Explain the applications of packing

    Explain the applications of packing life cycle.

  • Q : Requirement of Timer control in AJAX

    Explain the requirement of a Timer control in the AJAX.

  • Q : Uses of BYTE Write a program that shows

    Write a program that shows the uses of BYTE, WORD and DWORD?

  • Q : What is Discrete simulation Discrete

    Discrete simulation: In a discrete simulation, the time passes at an irregular rate which is determined by the primary events of interest in simulation.

  • Q : Explain the applications of testing

    Explain the applications of testing life cycle.

  • Q : Explain Base type Base type : The kind

    Base type: The kind of items that might be stored in an array - the arrays defined type. For example, in     int[] numbers; the base type

  • Q : What is an Instance variable Instance

    Instance variable: It is a non-static field of a class. Each and every individual object of a class has its own copy of this field. This is in contrary to a class variable that is shared by all instances of class. Instance variables are employed to mo

  • Q : Explain Copy constructor Copy

    Copy constructor: It is a constructor which takes a single argument of similar class. For illustration:     public class Point {        

  • Q : Explain Primitive Type Abstractions

    Primitive Type Abstractions: An effective way to reduce the state space of a program is to replace the primitive types with the corresponding abstractions that encapsulate all the possible operations that are performed on these types.

    Discover Q & A

    Leading Solution Library
    Avail More Than 1436362 Solved problems, classrooms assignments, textbook's solutions, for quick Downloads
    No hassle, Instant Access
    Start Discovering

    18,76,764

    1928738
    Asked

    3,689

    Active Tutors

    1436362

    Questions
    Answered

    Start Excelling in your courses, Ask an Expert and get answers for your homework and assignments!!

    Submit Assignment

    ©TutorsGlobe All rights reserved 2022-2023.