candybox.h
来自「Visual C++ 2005的源代码」· C头文件 代码 · 共 35 行
H
35 行
// CandyBox.h in Ex9_03
#pragma once
#include <iostream>
#include "Box.h"
using std::cout;
using std::endl;
class CCandyBox: public CBox
{
public:
char* m_Contents;
// Constructor to set dimensions and contents
// with explicit call of CBox constructor
CCandyBox(double lv, double wv, double hv, char* str = "Candy")
:CBox(lv, wv, hv)
{
cout << endl <<"CCandyBox constructor2 called";
m_Contents = new char[ strlen(str) + 1 ];
strcpy_s(m_Contents, strlen(m_Contents), str);
}
// Constructor to set contents
// calls default CBox constructor automatically
CCandyBox(char* str = "Candy")
{
cout << endl << "CCandyBox constructor1 called";
m_Contents = new char[ strlen(str) + 1 ];
strcpy_s(m_Contents, strlen(m_Contents), str);
}
~CCandyBox() // Destructor
{ delete[] m_Contents; }
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?