找不到成员声明
Member declaration not found?
我正在Eclipse中编写一个C++应用程序,在编写一些代码时,我在ch_type.cpp的第18、27、41和81行发现了几个错误
ch_type.h
/********************************************************
* char_type -- Character type class *
* *
* Member functions: *
* type -- returns the type of a character *
* (Limited to simple types) *
* is(ch, char_type) -- check to see if ch is *
* a member of the given type. *
* (Works for derrived types as well.) *
*******************************************************/
class char_type {
public:
enum CHAR_TYPE {
C_EOF, // End of file character
C_WHITE, // Whitespace or control character
C_NEWLINE, // A Newline character
C_ALPHA, // A Letter (includes _)
C_DIGIT, // A number
C_OPERATOR, // Random operator
C_SLASH, // The character '/'
C_L_PAREN, // The character '('
C_R_PAREN, // The character ')'
C_L_CURLY, // The character '{'
C_R_CURLY, // The character '}'
C_SINGLE, // The character '''
C_DOUBLE, // The character '"'
// End of simple types, more complex, derrived types follow
C_HEX_DIGIT, // Hexidecimal digit
C_ALPHA_NUMERIC // Alpha numeric
};
private:
static enum CHAR_TYPE type_info[256]; // information of each character
// Fill in a range of type info stuff
void fill_range(int start, int end, CHAR_TYPE type);
public:
char_type(); // Initialize the data
//~char_type -- default destructor
// Returns true if character is a given type
int is(int ch, CHAR_TYPE kind);
CHAR_TYPE type(int ch);
}
ch_type.cpp
/********************************************************
* ch-type package *
* *
* The class ch_type is used to tell the type of *
* various characters *
* *
* The main number functions are: *
* is -- True if the character is the indicated *
* type. *
* type -- Return type of character. *
*******************************************************/
#include <iostream>
#include <assert.h>
#include "ch_type.h"
// Define the type information array
char_type::CHAR_TYPE char_type::type_info[256];
/********************************************************
* fill_range -- fill in a range of types for the *
* character type class *
* *
* Parameters *
* start, end -- range of items to fill in *
* type -- type to use for filling *
*******************************************************/
void char_type::fill_range(int start, int end, CHAR_TYPE type)
{
int cur_ch;
for (cur_ch = start; cur_ch <= end; ++cur_ch) {
assert(cur_ch >= 0);
assert(cur_ch < sizeof(type_info)/sizeof(type_info[0]));
type_info[cur_ch] = type;
}
}
/*********************************************************
* char_type::char_type -- initialize the char type table*
********************************************************/
char_type::char_type()
{
fill_range(0, 255, C_WHITE);
fill_range('A', 'Z', C_ALPHA);
fill_range('a', 'z', C_ALPHA);
type_info['_'] = C_ALPHA;
type_info['!'] = C_OPERATOR;
type_info['#'] = C_OPERATOR;
type_info['$'] = C_OPERATOR;
type_info['%'] = C_OPERATOR;
type_info['^'] = C_OPERATOR;
type_info['&'] = C_OPERATOR;
type_info['*'] = C_OPERATOR;
type_info['-'] = C_OPERATOR;
type_info['+'] = C_OPERATOR;
type_info['='] = C_OPERATOR;
type_info['|'] = C_OPERATOR;
type_info['~'] = C_OPERATOR;
type_info[','] = C_OPERATOR;
type_info[':'] = C_OPERATOR;
type_info['?'] = C_OPERATOR;
type_info['.'] = C_OPERATOR;
type_info['<'] = C_OPERATOR;
type_info['>'] = C_OPERATOR;
type_info['/'] = C_SLASH;
type_info['n'] = C_NEWLINE;
type_info['('] = C_L_PAREN;
type_info[')'] = C_R_PAREN;
type_info['{'] = C_L_CURLY;
type_info['}'] = C_R_CURLY;
type_info['"'] = C_DOUBLE;
type_info['''] = C_SINGLE;
}
int char_type::is(int ch, CHAR_TYPE kind)
{
if (ch == EOF) return (kind == C_EOF);
switch (kind) {
case C_HEX_DIGIT:
assert(ch >= 0);
assert(ch < sizeof(type_info)/sizeof(type_info[0]));
if (type_info[ch] == C_DIGIT)
return (1);
if ((ch >= 'A') && (ch <= 'F'))
return (1);
if ((ch >= 'a') && (ch <= 'f'))
return (1);
return (0);
case C_ALPHA_NUMERIC:
assert(ch >= 0);
assert(ch < sizeof(type_info)/sizeof(type_info[0]));
return ((type_info[ch] == C_ALPHA) ||
(type_info[ch] == C_DIGIT));
default:
assert(ch >= 0);
assert(ch < sizeof(type_info)/sizeof(type_info[0]));
return (type_info[ch] == kind);
}
};
我做错了什么?如何修复这些错误?
这是我的错误信息:
描述资源路径位置类型
未找到成员声明ch_type.cpp/stats第18行语义错误
首先,在类定义之后,必须插入;
class char_type {
...
}; //HERE
其次,要使用宏EOF
,必须包含<stdio.h>
相关文章:
- 在指向现有内存地址的 hpp 文件中声明成员函数的最佳方法
- 如何使用模板声明成员函数?(不是模板类)
- 如何使用 Boost.Hana 声明成员变量
- 声明成员对象而不调用其默认构造函数
- 使用函数类型语法声明成员函数
- 尝试访问标头声明成员时出现隔离错误
- 根据二手构造函数声明成员
- C 模板明确声明成员函数值/避免了宏的问题
- 如何在基本模板类中声明成员,其中类型取决于派生类的类型
- 错误:类中没有声明成员函数
- 我可以使用相同的名称为周围作用域中的类型声明成员类型别名吗
- 从variadic模板参数声明成员变量
- 在类(C )中使用模板时未声明成员函数
- 错误:类中未声明 '' 成员函数
- 如何在指向常量地址时声明成员函数常量指针
- 何时以及为什么在堆C++上声明成员变量
- C++ 错误:未在范围内声明;成员函数
- 在不声明成员变量的情况下更改按钮颜色
- 错误 C2535:已定义或声明成员函数
- 当声明成员函数时,*New()是什么意思