//메인함수 파트
#include <iostream>
using namespace std;
#include "Exp.h"
int main(){
Exp a(3,2);
Exp b(9);
Exp c;
cout << a.getValue() << ' ' << b.getValue() << ' ' << c.getValue() << ' ' <<endl;
cout << "a의 베이스" << a.getBase() << ',' << "지수" << a.getExp() <<endl;
if(a.equals(b)){
cout << "same" << endl;
}
else
cout << "not same" << endl;
}
//헤더파일 파트
#ifndef EXP_H
#define EXP_H
//클래스 헤더 파일은 선언부만 적어주기
class Exp
{
private:
int base;//멤버변수 선언부,베이스
int jisoo;//지수
int res;
public:
Exp();
Exp(int x);
Exp(int x, int y);
int getValue();//멤버함수 선언부
int getBase();
int getExp();
bool equals(Exp x);
};
#endif
//헤더파일 구현부
#include "Exp.h"
#include <math.h>
//클래스 구현부
Exp::Exp(){
base =1;
jisoo =1;
}
Exp::Exp(int x){
base =x;
jisoo =1;
}
Exp::Exp(int x, int y){
base =x;
jisoo =y;
}
int Exp::getValue(){
res = pow(base,jisoo);
return res;
}
int Exp::getBase(){
return base;
}
int Exp::getExp(){
return jisoo;
}
bool Exp::equals(Exp X){
if(X.getValue() == res){
return true;
}
}