datatype.h
来自「常用算法与数据结构原代码」· C头文件 代码 · 共 45 行
H
45 行
#ifndef DataType_
#define DataType_
class DataType
{
friend void main(void);
friend ostream& operator<<(ostream&,const DataType&);
friend istream& operator>>(istream&,DataType&);
public:
DataType(int k=0,char i=' ')
{
key=k;
ID=i;
}
~DataType()
{
}
operator int() const {return key;}
DataType& operator =(const DataType&);
private:
int key; // element key
char ID; // element identifier
};
ostream& operator<<(ostream& out,const DataType& x)
{
out << x.key << ' ' << x.ID << ' ';
return out;
}
istream& operator>>(istream& in ,DataType& x)
{
cin>>x.key >>x.ID;
return in;
}
DataType& DataType::operator =(const DataType& x)
{
key=x.key;
ID=x.ID;
return *this;
}
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?