intentry.h
来自「此程序为求两个数的约数,将他们输出,将这两个数的最大公约数输出」· C头文件 代码 · 共 46 行
H
46 行
#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 + =
减小字号Ctrl + -
显示快捷键?