注册 登录
编程论坛 C++教室

求助这个代码面积部分的主函数不会写,以及要在这个函数里加上const函数和析构函数

遗情处有诗章 发布于 2017-10-22 15:10, 1320 次点击
程序代码:
// ConsoleApplication37.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include<iostream>
#include<string>
using namespace std;
class homepage {
public:
    homepage(string p, int h, int w);
    ~homepage()
    {
        cout << "delete";
    }
        void display();
    protected:
        string photo;
        int height;
        int width;

};
class area :public homepage
{
public:
    int getArea()
    {
        return (height*width);
    }
    void putout();
};
homepage::homepage(string p, int h, int w)
{
    photo =p;
    height = h;
    width = w;
}

void homepage::display()
{
    cout << "photo:" << photo << "," << "height:" << height << "," << "width:" << width << endl;
}
void area::putout()
{
    cout << "面积:" << ""<<endl;
}
int main()
{
    homepage h("qwertyui",12,11);
    h.display();
    system("pause");
    return 0;
}



[此贴子已经被作者于2017-10-22 15:11编辑过]

0 回复
1