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 11:50, local time: 2024/11/27 03:55,
TOP NEW HELP FIND: 
18.217.10.200: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!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .