c++繼承經典例子
#include
class
{
private:
public:
};
class
{
private:
public:
//
};
int
{
}
//Example:
#include
#include
class
{
virtual
~Thing(){cout<<"Thing
};
class
{
public:
virtual
~Animal(){cout<<"Animal
};
void
{
}
純虛擬函式,多型#include
#include
class
{
private:
public:
};
class
{
private:
public:
Point&
{
return
}
{
center
draw(
}
//
};
class
{
private:
public:
};
class
{
private:
public:
};
int
{
s.vertices(
//
}
////////////////////////////////////////////////////////////////////
#include
#include
class
{
public:
virtual
~Thing(){cout<<"Thing
};
class
{
public:
virtual
~Animal(){cout<<"Animal
};
void
{
}
多繼承
#include
class
{
private:
public:
};
class
{
private:
public:
};
class
{
public:
};
int
{
//
}
共同基類的多繼承
#include
class
{int
public:
class
{
int
public:
class
{
int
public:
class
{
int
public:
C(int
};
int
{
A
B
aa.printOn();
bb.printOn();
虛基類
#include
class
{
public:
};
class
{
public:
};
class
{int
public:
};
class
{
public:
//
C(int
void
};
void
{
}
////////////////////////////////////////
#include
class
{
public:
};
class
{
protected:
public:
};
class
{
protected:
public:
};
class
{
protected:
public:
C(int
void