1
大家好,我在這裏是新的,我在嵌套類中聲明構造函數時出錯。C++錯誤C4091當繼承嵌套類
可以說我有一個名爲Event的類,在SampleEvent和TimeEvent構造函數中有2個繼承它的SampleEvent和TimeEvent的嵌套類,但有一個錯誤。
這裏是我的代碼:
// Event Class
#ifndef EVENT_H
#define EVENT_H
#include <iostream>
namespace Engine
{
namespace Data
{
class Event
{
public:
// Class Variable
int Measure;
int Beat;
int Position;
// This Class that was I mean
class SampleEvent;
class TimeEvent;
// Constructor
Event(int measure, int beat, int pos);
};
// Sample Event Class
class Event::SampleEvent : public Event
{
public:
// variable in SampleEvent Class
int ID;
float Pan;
float Vol;
// Constructor
SampleEvent(int id, float pan, float vol, int measure, int beat, int pos);
};
// Time Event Class
class Event::TimeEvent : public Event
{
public:
// variable in TimeEvent Class
double Value;
// Constructor
TimeEvent(double value, int measure, int beat, int pos);
};
// Constructor of Event
Event::Event(int measure, int beat, int pos)
{
Measure = measure;
Beat = beat;
Position = pos;
}
// Constructor of Sample Event
Event::SampleEvent::SampleEvent(int id, float pan, float vol, int measure, int beat, int pos) : Event::Event(measure, beat, pos)
{
ID = id;
Pan = pan;
Vol = vol;
Measure = measure;
Beat = beat;
Position = pos;
}
// Constructor of Time Event
Event::TimeEvent::TimeEvent(double value, int measure, int beat, int pos) : Event::Event(measure, beat, pos)
{
Value = value;
Measure = measure;
Beat = beat;
Position = pos;
}
}
}
#endif
這給我2錯誤:
Error C2039: '{ctor}' : is not a member of 'Engine::Data::Event' (line 60)
Error C2039: '{ctor}' : is not a member of 'Engine::Data::Event' (line 71)
有人可以幫助我嗎? 謝謝
感謝您的回覆,看後,我已經修改了代碼,但仍然得到同樣的錯誤 – SirusDoma 2013-03-26 03:14:44
@ChronoCross:將'Event :: Event'改爲'Event'。 – 2013-03-26 03:17:42
哇謝謝,解決我的問題(y)謝謝 – SirusDoma 2013-03-26 03:20:39