码迷,mamicode.com
首页 > 系统相关 > 详细

Hibernate复习(五)对象的三种状态和缓存机制

时间:2014-05-08 05:01:15      阅读:310      评论:0      收藏:0      [点我收藏+]

标签:style   blog   class   code   ext   int   

#include <iostream>
#include <cmath>
using namespace std;
class Point
{
public:
    Point(double x=0,double y=0);
    void setPoint(double,double);
    double getx()
    {
        return x;
    }
    double gety()
    {
        return y;
    }
    void display();
protected:
    double x,y;
};
class Circle:public Point
{
public:
    Circle(double x=0,double y=0,double R=0);
    void setR(double,double,double);//半径
    double getR()
    {
        return R;
    }
    double areas();//圆面积
protected:
    double R;
};
Point::Point(double a,double b)
{
    x=a;
    y=b;
}
void Point::setPoint(double a,double b)
{
    x=a;
    y=b;
}
void Point::display()
{
    cout<<"( "<<getx()<<","<<gety()<<")"<<endl;
}
Circle::Circle(double a,double b,double r):Point(a,b),R(r) {}
void Circle::setR(double a,double b,double r)
{
    x=a;
    y=b;
    R=r;
}
double Circle::areas()
{
    return 3.14*R*R;
}
int main()
{
    Point p1(3,3),p2(8,8);
    Circle c(2,2,4);
    cout<<"第一点";
    p1.display();
    cout<<"第二点";
    p2.display();
    cout<<"原点为:"<<"( "<<c.getx()<<","<<c.gety()<<")"<<" 半径为:"<<c.getR()<<" 的圆的面积为:"<<c.areas()<<endl;
    return 0;
}

bubuko.com,布布扣

感悟:大晚上的在宿舍编程序也不错啊!

Hibernate复习(五)对象的三种状态和缓存机制,布布扣,bubuko.com

Hibernate复习(五)对象的三种状态和缓存机制

标签:style   blog   class   code   ext   int   

原文地址:http://blog.csdn.net/caicongyang/article/details/25243619

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!