文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C++简单类 与 PHP相似之处

C++简单类 与 PHP相似之处

时间:2011-05-23  来源:flyhacker

class cBox {
    public:
        double m_Length;
        double m_Width;
        double m_Height;

        double Volume(void);
};

int main() {

    cBox box1;
    cBox box2;

    double boxVolume(0.0);

    box1.m_Height = 18.0;
    box1.m_Length = 78.0;
    box1.m_Width = 24.0;

    box2.m_Height = box1.m_Height - 10;
    box2.m_Length = box1.m_Length / 2.0;
    box2.m_Width  = 0.25 * box1.m_Length;

    boxVolume = box1.Volume();

    cout << endl
        << "Volume of box1 = " << boxVolume;
    cout << endl
        << "box2 has sides which total "
        << box2.Volume() << " inches." << endl;

    cout << "A CBOx:" << sizeof box1 << " bytes." << endl;

    return 0;
}

double cBox::Volume() {
    return m_Length * m_Width * m_Height;
}

//result
33696
6084
24
相关阅读 更多 +
排行榜 更多 +
热血帝王139g官方版下载

热血帝王139g官方版下载

模拟经营 下载
三角洲摸金模拟器下载

三角洲摸金模拟器下载

休闲益智 下载
卖菜致富记游戏官方版下载

卖菜致富记游戏官方版下载

休闲益智 下载