分文件组织工程结构:
1、一个包含类定义的头文件,文件名就是自己的类名
#ifndef RECTANGLE_H_INCLUDED
#define RECTANGLE_H_INCLUDED
class Rectangle
{
private:
float width;
float length;
float area;
char *boxName;
//函数在类内定义,称为内联函数,不需要作用域分辨符
//将代码较少的函数定义为内联函数,可以减少函数调用时的开销
void calcArea(void){area = width * length;}
public:
//内联构造函数
Rectangle()
{
//构造函数的功能之一,就是初始化默认参数,并进行动态内存分配
boxName = new char[128];
cout<<"this is the constructor!\n\n";
}
//内联析构函数,释放之前动态申请的空间,进行善后处理
~Rectangle()
{
delete []boxName;
cout<<"this is the des