vc++初始化wenti.txt

来自「此加密算法是用vc实现」· 文本 代码 · 共 86 行

TXT
86
字号
定义的类
string
{
private:
static const int CINLIM = 80;
....
public:
friend istream & operator>>(istream & is, String & st); //友元
}

istream & operator>>(istream & is, String & st)
{
    char temp[String::CINLIM];
    is.get(temp, String::CINLIM);  
    if (is)
        st = temp;
    while (is && is.get() != '\n')
        continue;
    return is; 
}
运行在VC6下,编译时出现:
illegal pure syntax,must be '=0'
pure specifier can only be specified for functions

 
 
 
 
  
 回复内容 
【akirya】:
string
{
private:
static const int CINLIM = 80;
....
public:
friend istream & operator>>(istream & is, String & st); //友元
}
改为
string
{
private:
static const int CINLIM;
....
public:
friend istream & operator>>(istream & is, String & st); //友元
}
const int string::CINLIM = 80;

【taodm】:
VC6不支持static const。要么换编译器,要么用enum实现。

【Allengo】:
string
{
private:
static const int CINLIM;
....
public:
friend istream & operator>>(istream & is, String & st); //友元
}
const int string::CINLIM = 80;

这样有什么作用?
用enum可以实现

【xlbdan】:
static const int string::CINLIM = 80;

这种表达方法VC6并不支持,你可以像楼上说的那样分开写,在类内写

static const int CINLIM

在类外写

const int string::CINLIM = 80;


用enum的话就在类内写:eunm{CINLIM=80},即可使用

【Allengo】:
谢谢~~
 
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?