第七周项目2-自选图形用户界面程序开发

来源:互联网 发布:2017年mac游戏推荐 编辑:程序博客网 时间:2024/06/06 05:28

经过这几天的使用VS,发现其实和VB还是有一些相同的地方,所以对于控件还是能够很好的了解他们的作用。

这是今天上机的时候写得一个“长方体求解”的程序,主要还是多练习练习,熟悉一下。

创建一个“Bank”项目,在bankget.h中,创建一个类:

class Bank{private:int leight;int weight;int height;public:void get(int, int, int);int getarea();int getvo();};

在bankget.cpp中,完成内置函数的声明:

#include "stdafx.h"#include "Bank.h"#include "bankget.h"void Bank::get(int l, int w, int h){leight = l;weight = w;height = h;}int Bank::getarea(){return (2 * (leight*weight + weight*height + leight*height));}int Bank::getvo(){return (leight*height*weight);}

在BankDlg.cpp中,增加对按钮button的函数实现:

void CBankDlg::OnBnClickedButton1(){UpdateData();Bank b1;b1.get(b_l, b_w, b_h);b_area = b1.getarea();b_vo = b1.getvo();UpdateData(false);}

结果如图:



@ Mayuko


1 0
原创粉丝点击