Hello, Olufowobi.
Your code:
>I need to achieve class constant for integral type
>________________________________
>
>class Ball{
>static const int radius = 10;
>};
>
>I have tried,
>class Ball
>{
>const static double radius ;
>
>};
>Ball::radius = 10.0;
>
>________________________________
Answer:
//==============================================================================
#include <iostream.h>
#pragma argsused //pragma of Borland C++ Builder 5.
//==============================================================================
class Ball
{
const double radius;
const static double circle;
public:
Ball():radius(12.3){} //Initialise value 'radius' in construtor
void print();
};
//==============================================================================
const double Ball::circle=1.2;
//==============================================================================
void Ball::print()
{
cout << "radius = " << Ball::radius << endl;
cout << "circle = " << Ball::circle << endl;
}
//==============================================================================
int main(int argc, char* argv[])
{
Ball ball;
ball.print();
return 0;
}
//==============================================================================
//Screen output:
//D:\SWSETUP>ball
//radius = 12.3
//circle = 1.2
//D:\SWSETUP>
//==============================================================================
--
Gleb mailto:[email protected]
Подарки на 8 марта! На любой вкус и кошелек!
http://r.mail.ru/cln6702/torg.mail.ru/
------------------------------------
To unsubscribe, send a blank message to
<mailto:[email protected]>.Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/c-prog/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/