C++ error C2143 syntax error : missing ';' before function name
C++ error C2143 syntax error : missing ';' before function name
我有头文件:
#ifndef VIP_TICKET_H
#define VIP_TICKET_H
#include "ticket.h"
class VIPTicket : public Ticket
{
public:
enum VIPType { FIRST_CLASS, FAST_LINE };
VIPType getTicketType() const;
private:
VIPType type;
};
#endif
而且是cpp文件
#include "vipTicket.h"
VIPType VIPTicket::getTicketType() const
{
return type;
}
错误显示“error C2143: 语法错误:缺少‘;’在 'VIPTicket::getTicketType' 之前“
这个错误非常令人困惑..我想这不是';'那是丢失的,但可能是我无法确定的代码有其他问题..
这个定义有问题
VIPType VIPTicket::getTicketType() const
{
...
}
当你定义这个函数时你必须记住VIPType
不在全局范围内,而是在VIPTicket
class的范围内,所以你必须明确提及范围:
VIPTicket::VIPType VIPTicket::getTicketType() const
{
...
}
我有头文件:
#ifndef VIP_TICKET_H
#define VIP_TICKET_H
#include "ticket.h"
class VIPTicket : public Ticket
{
public:
enum VIPType { FIRST_CLASS, FAST_LINE };
VIPType getTicketType() const;
private:
VIPType type;
};
#endif
而且是cpp文件
#include "vipTicket.h"
VIPType VIPTicket::getTicketType() const
{
return type;
}
错误显示“error C2143: 语法错误:缺少‘;’在 'VIPTicket::getTicketType' 之前“
这个错误非常令人困惑..我想这不是';'那是丢失的,但可能是我无法确定的代码有其他问题..
这个定义有问题
VIPType VIPTicket::getTicketType() const
{
...
}
当你定义这个函数时你必须记住VIPType
不在全局范围内,而是在VIPTicket
class的范围内,所以你必须明确提及范围:
VIPTicket::VIPType VIPTicket::getTicketType() const
{
...
}