2008.05.09 10:07

(C++) 클래스 생성자 관련 예제2

#include<iostream>
using namespace std;
class Point
{
public:
 int x,y;
 void Print();
 Point(int initialX, int initialY);
};
Point::Point(int initialX, int initialY) <---
{
 x=initialX;
 y=initialY;
}
void Point::Print()
{
cout<<"("<<x<<","<<y<<")\n";
}
int main()
{
 Point pt(3,5); <--
 pt.Print();
 return 0;
}
Trackback 0 Comment 1