달력

2

« 2025/2 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
2012. 9. 25. 15:47

c++ struct와 class의 차이점...????? c++2012. 9. 25. 15:47

#include
#include

using namespace std;

class Point{

    public:
    Point(int x, int y);

    void setX(int newVal);
    void setY(int newVal);
};

struct RectData{

    Point ulhc;
    Point lrhc;
};

class RectData2{

public:
    Point a;
    Point b;
    void get(){};
};



class Rectangle{

public:
//객체에 직접 접근할 때는 포인터 연산자로 데이터 접근가능
//실객체의 함수를 호출할 때는 *,get()함수를 이용해서 호출함.
    Point& upperLeft() const { return pData->ulhc;}
    Point& lowerRight() const { return pData->lrhc;}
    Point& p() const { return a->a; }
    void v() { (*a).get();}

private:
    std::tr1::shared_ptr pData;
    std::tr1::shared_ptr a;

};

int main()
{
    return 0;
}


'c++' 카테고리의 다른 글

c++ quiz3  (0) 2012.09.27
c++ strategy 패턴  (0) 2012.09.27
Quiz2  (0) 2012.09.26
다형성과 tr1::shared_ptr을 이용한 벡터 사용  (0) 2012.09.25
가상함수  (0) 2012.09.25
:
Posted by НooпeУ


Code Start Code End