--%>

"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 Implements clause Implements

    Implements clause: That part of a class header which points out which interfaces are applied by the class. A class might implement for more than one interface.

  • Q : Use of UpdateProgress control in AJAX

    What is the use of UpdateProgress control in AJAX?

  • Q : Differences between XHTML and HTML

    Explain the differences between XHTML and HTML?

  • Q : Define Java virtual machine or JVM

    Define Java virtual machine (JVM): A Java Virtual Machine (JVM) is an abstract computing machine, or virtual machine (set of computer software programs and data structures) which is a platform-independent execution environment that converts Java bytec

  • Q : Basic features of OOPs Illustrate the

    Illustrate the basic features of OOPs?

  • Q : Block Started by Symbol What is the

    What is the Block Started by the Symbol?

  • Q : Different services provided by DLR to

    Give details about the different services that are provided by DLR to CLR?

  • Q : Define TCP endpoint TCP endpoint : It

    TCP endpoint: It is the combination of an IP address and Transmission Control Protocol (abbreviated as TCP) port number.

  • Q : What is an Interrupt Interrupt : This

    Interrupt: This is an asynchronous message sent to a process or thread which interrupts what it is at present doing. This generally outcomes in an InterruptedException object being received by an interrupted thread. Waiting for an int

  • Q : Explain This This : It is a Java

    This: It is a Java reserved word with numerous different uses: A) Within a constructor, it might be employed as the first statement to call the other constructor in similar class. For illustration:

    Discover Q & A

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

    18,76,764

    1960842
    Asked

    3,689

    Active Tutors

    1431883

    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.