U E D R , A S I H C RSS

삼총사Cpp Study/Inheritance

. 길
StarCraft .(.-_- .) .

~cpp 
class CMarine //   
{
private:
    int m_Attack;
    int m_Defence;
    int m_HP;
public:
    void Attack() { //  공격!! }
};

class CFirebat //   
{
private:
    int m_Attack;
    int m_Defence;
    int m_HP;
public:
    void Attack() { //  공격!! }
};

. 기 .
. .

~cpp 
CMarine Force[12]; //     .
CFirebat Force[12]; //     .
.. 까~? (Inheritance).


~cpp 
class CUnit
{
protected: // protected         .
    int m_Attack;
    int m_Defence;
    int m_HP;
public:
    void Attack();
};
.

~cpp 
class CMarine : public CUnit // .
{
public:
    void Attack() { //  공격! }
};

class CFirebat : public CUnit
{
public:
    void Attack() { //  공격! }
};



~cpp 
CUnit Force1[12]; //  ,    .

.
----
CppStudy
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:29:39
Processing time 0.0105 sec