종합적인..
페이지 정보
본문
// private: public:
#include<iostream>
#include<conio.h>
using namespace std;
class A
{
int x;
int y;
char yon;
int tot;
public:
A();
void sum();
void disp()
{
cout << x <<" " << yon << " " << y <<" = " << tot <<endl;
}
};
A::A()
{
cout << " x = ";
cin >> x;
cout << " yon = ";
cin >> yon;
fflush(stdin); // 버퍼 삭제
cout << " y = ";
cin >> y;
}
void A::sum()
{
switch(yon)
{
case '+':tot =x + y; break;
case '-':tot =x - y; break;
case '*':tot =x * y; break;
case '/':tot =x / y; break;
case '%':tot =x % y; break;
default : cout << " error .." <<endl;
exit(0);
}
}
void main()
{
A cc;
cc.sum();
cc.disp();
getch();
}
#include<iostream>
#include<conio.h>
using namespace std;
class A
{
int x;
int y;
char yon;
int tot;
public:
A();
void sum();
void disp()
{
cout << x <<" " << yon << " " << y <<" = " << tot <<endl;
}
};
A::A()
{
cout << " x = ";
cin >> x;
cout << " yon = ";
cin >> yon;
fflush(stdin); // 버퍼 삭제
cout << " y = ";
cin >> y;
}
void A::sum()
{
switch(yon)
{
case '+':tot =x + y; break;
case '-':tot =x - y; break;
case '*':tot =x * y; break;
case '/':tot =x / y; break;
case '%':tot =x % y; break;
default : cout << " error .." <<endl;
exit(0);
}
}
void main()
{
A cc;
cc.sum();
cc.disp();
getch();
}
댓글목록
등록된 댓글이 없습니다.