--%>

"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 : How authorities save their Private Keys

    How do certifying authorities save their Private Keys?

  • Q : Criticizing CORBA technology Criticize

    Criticize the process by which the CORBA technology was designed and implemented.

  • Q : Explain the Automated Software testing

    Explain the Automated Software testing life cycle.

  • Q : Define the term Base case Define the

    Define the term Base case: It is a non-recursive route via a recursive method.

  • Q : Explain the benefits of distributed

    Explain the benefits of distributed systems.

  • Q : Define the term Runtime error Define

    Define the term Runtime error: It is an error which causes a program to finish whenever it is being run.

  • Q : What is an Anonymous class Anonymous

    Anonymous class: It is a class formed without a class name. Such a class will be a sub class or an implementation of an interface, and is generally formed as an actual argument or returned as a method outcome. For example:

    Q : Programming with C# QUESTION 1      

    QUESTION 1       The following UML diagram describes an abstract class Customer. This class is to be used as part of a Company's inventory system. The inventory system will contain many different types of customers.  A separate s

  • Q : What is Pattern Pattern : It is a

    Pattern: It is a recurring theme in class usage or design. Interfaces like Iterator encapsulate a pattern of admission to the items in a collection, whereas freeing the client from the requirement to know details of the way in which the collection is

  • Q : Search and Coverage of SPIN Search and

    Search and Coverage of SPIN: SPIN has a highly optimized state exploration algorithm. It supports random, interactive and guided simulation, and both exhaustive and partial coverage, based on either depth-first or breadth-first search.

    Discover Q & A

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

    18,76,764

    1945594
    Asked

    3,689

    Active Tutors

    1451761

    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.