プロが教えるわが家の防犯対策術!

あるクラスの中で、他のクラスを定義したいのですが、なぜかできません。。助けて下さい!!


class VanHelsing
{
    ~省略~
{

class Enemy
{
    ~省略~
}

class DraculaCastle
{
    VanHelsing vh;
    Enemy mi;    <同じベースのステータス
    Enemy cd;    <が違うもの
public:
    DraculaCastle();
    void Play();
};


DraculaCastle::DraculaCastle()
:mi(100+rand()%10*10, rand()%10, rand()%5*5, 0, 20+rand()%2*10)
:cd(300, rand()%10, 30, 0, 30+rand()%3*10)
{
    cout << "<you enter the dark castle of Count Draculia>" << endl;
    cout << "<everything around you is dusty>" << endl;
    cout << "<then, you sense a presence over you... looking down upon you>" << endl;
    cout << "<you look up>" << endl;
    cout << "<suddently, a dark shape falls off one of the main pillars supporting the battlements>" << endl;
    ~省略~
    cout << "<your remaining HP>:" << vh.GetHP() << endl;
    cout << "<your remaining MP>:" << vh.GetMP() << endl;
    cout << "<Enemy's remaining HP>:" << mi.GetHP() << endl;
}

A 回答 (1件)

初期化子の書き方が間違ってるだけじゃ?

    • good
    • 0
この回答へのお礼

DraculaCastle::DraculaCastle()
:mi(100+rand()%10*10, rand()%10, rand()%5*5, 0, 20+rand()%2*10)
:cd(300, rand()%10, 30, 0, 30+rand()%3*10)

DraculaCastle::DraculaCastle()
:mi(100+rand()%10*10, rand()%10, rand()%5*5, 0, 20+rand()%2*10),
cd(300, rand()%10, 30, 0, 30+rand()%3*10)

と書けばいいらしいです!!ありがとうございました!!

お礼日時:2007/02/08 21:46

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!