#include <iostream>
#include <cstdlib>
using namespace std;
class Rectangle{
int width;
int height;
public:
int getArea();
void set_width(int w);
void set_height(int h);
};
void Rectangle::set_width(int w){
w = width;
};
void Rectangle::set_height(int h){
h = height;
};
int Rectangle::getArea(){
return width*height;
}
int main()
{
Rectangle rect;
rect.set_width(3);
rect.set_height(5);
cout <<"사각형의 면적은"<< rect.getArea()<<endl;
system("pause");
}
지금 객채쪽을 공부중입니다. 혼자서 만들어봤는데.
정상적인 값이라면 15가 나와야 정상이지만 실제로 디버깅 해보면
오류는 안뜨는데 687194768 이라는 답이 나와, 고민중입니다.
오류라도 뜨면 어떻게 수정을 해보겠는데, 오류도 안뜨고 답은 틀리니
정말 궁금합니다. 혹시 답변 해주실수 있으신지요?