#include<iostream>
#include<assert.h>
using namespace std;
class Mod{
public:
Mod(){}
Mod(unsigned int a): m(a){}
~Mod(){}
unsigned int get_modulo() const;
void set_modulo(int);
unsigned int get_m() const;
static void valid(Mod &);
friend Mod operator+(const Mod&, const Mod&);
friend Mod operator-(const Mod&, const Mod&);
friend Mod operator*(const Mod&, const Mod&);
friend bool operator==(const Mod& , const Mod&);
friend bool operator!=(const Mod&, const Mod&);
friend std
::ostream& operator<<(std
::ostream& cout,
const Mod
&);
Mod operator++();
Mod operator++(int);
Mod operator--();
Mod operator--(int);
unsigned int pot(const unsigned int); // (a^n) mod q
private:
static unsigned int q;
unsigned int m;
};
unsigned int Mod::q=9;
void Mod::valid(Mod & mod)
{
assert(mod.m < q);
assert(mod.m >= 0);
}
int main()
{
Mod mod(6);
mod.valid(mod);//vẫn là phương thức của lớp không giống hàm friend tự do
system("pause");
return 0;
}