大家好,我是新来的,在嵌套类中声明构造函数时出现错误。
假设我有一个名为 Event 的类,有 2 个继承它的嵌套类 SampleEvent 和 TimeEvent,在 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)
有人能帮我吗?谢谢