|
c++로 한건데...
문제는 이거고요..
기본 클래스 Point는 추상 클래스로 GetArea()를 멤버로 가지고 있다.
이것을 상속하여 int x, y 좌표와 GetArea()를 가지고 있는
Point2D 클래스와 int x, y, z 좌표와 GetArea()를 가지고 있는 Point3D 클래스를 정의한다.
GetArea()는 원점을 기준으로 사각형 면적과 육면체 부피를 계산하여 출력한다.
두 클래스 모두 x, y, z를 1, 2, 3으로 초기화하는 생성자를 만든다.
main()에서는 Point 클래스 객체 포인터를 이용하여 면적과 부피를 출력한다.
point.cpp파일이고요
#include <iostream>
using namespace std ;
#include "point.h"
Point::Point(int xx, int yy )
{
x = xx ;
y = yy ;
}
void Point::GetArea()
{
return ;
}
point2D.cpp파일이고요
#include "point2D.h"
using namespace std ;
Point2D::Point2D( int xx, int yy )
{
x = xx ;
y = yy ;
}
int Point2D::GetArea()
{
return x * y ;
}
point3D.cpp파일이고요
#include <iostream>
#include "point3D.h"
using namespace std ;
Point3D::Point3D(int xx, int yy, int zz )
{
z = zz ;
}
int Point3D::GetArea()
{
return x * y * z ;
}
test.cpp 파일이고요!
#include <iostream>
#include "point3D.h"
using namespace std ;
int main()
{
Point3D p3;
//printf("면적 or 부피 : %d\n", p3.GetArea() );
cout<< "면적 아니면 부피 :" <<"\n";
return 0;
}
point.h파일
#include <iostream>
class Point
{
public:
Point( int = 1, int = 2 );
void GetArea() ;
protected:
int x ;
int y ;
};
point2D.h 파일
#include "point.h"
class Point2D: public Point
{
public :
Point2D(int = 1 , int = 2) ;
int GetArea();
};
point3D.h파일!
#include "point2D.h"
class Point3D: public Point
{
public :
Point3D(int = 1, int = 2, int = 3);
int GetArea();
protected :
int z;
};
이렇게 파일을 나눠서 만들고 합쳐서 했는데
실행이 안되네요..
왜그런지요?^^
마무리좀 도와주세요~~~
|