📄 intentry.h
字号:
#ifndef INTENTRY_CLASS
#define INTENTRY_CLASS
#include <iostream>
using namespace std;
class intEntry
{
public:
intEntry(int v, int c): value(v), count(c)
{}//initialize the integer value and its count
int getValue() const
{
return value;
}
//return value
int getCount() const
{
return count;
}
//return count
void increment()
{
count++;
}
//invrement count
friend bool operator<(const intEntry& lhs,const intEntry& rhs)
{
if(lhs.count<rhs.count&&lhs.value==rhs.value) return true;
else return false;
}
friend bool operator==(const intEntry& lhs,const intEntry& rhs)
{
if(lhs.value==rhs.value) return true;
else return false;
}
//compare lhs and rhs using value
friend ostream& operator<<(ostream& ostr,const intEntry& obj)
{
ostr <<"Value = "<<obj.value<<" Count= "<<obj.count<<" ; ";
return ostr;
}
//output obj in format"value value ...value"(count times)
private:
int value;
int count;
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -