please dont rip this site

Language Ccpp Cppref Examples CONST1.CC

 
/**************************************************************************
 *
 * Language: C++
 * Purpose:  Program to demonstrate the 'new' statement.
 * Author:   M J Leslie
 * Date:     27-Sep-98
 *
 * Initialise a constant within a class.
 *
 **************************************************************************/

#include <iostream.h>                  // For cout.

class Math
{
public:
   
    // Constructor contains the definition of PI.

    Math() : PI(3.142) {}

    ~Math() {}
    
    float Diameter (float Radius)
    {
        return (Radius * PI);
    }

private:

    // Declare PI. We can not assign a value here.

    const float PI;
      
};

main()
{
    Math    Formula;
    float   Radius = 5;

    cout << " Radius is   " << Radius << endl;
    cout << " Diameter is " << Formula.Diameter(Radius) << endl;
}



file: /Techref/language/ccpp/cppref/EXAMPLES/const1.cc, 0KB, , updated: 1998/9/27 12:50, local time: 2024/4/27 00:53,
TOP NEW HELP FIND: 
3.139.86.56:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/techref/language/ccpp/cppref/EXAMPLES/const1.cc"> language ccpp cppref EXAMPLES const1</A>

Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .