《C/C++程序员实用大全》配套代码,适用初学C++的人员。
源代码在线查看: sizeof.cpp
#include
#include
class Base {
public:
Base(char *message) { strcpy(Base::message, message); };
void show_base(void) { cout private:
char message[256];
};
class Derived: public Base {
public:
Derived(char *dmsg, char *bmsg) : Base(bmsg) {
strcpy(message, dmsg); };
void show_derived(void)
{
cout show_base();
};
private:
char message[256];
};
void main(void)
{
Base some_base("This is a base");
Derived some_derived("Derived message", "Base message");
cout cout }