지금 열강 c++예제풀어보고잇는데
2장 2-3예제말이야
문제가 xpos, ypos두좌표잇는 Point struct만들고 뭐 두좌표 더하는 새로운좌표 만들어서 출력하는건데
예제 답안대로 한번해봣는데도 컴파일이 안되더라고..
#include <iostream>
using namespace std;

typedef struct__Point
{
 int xpos;
 int ypos;
}Point;

Point& PntAdder (const Point &p1, const Point &p2)
{
 Point *pptr=new Point;
 pptr->xpos= p1.xpos+p2.xpos;
 pptr->ypos= p1.ypos+p2.ypos;
 return *pptr;
}


int main(void)
{
 Point *p1 = new Point;
 p1->xpos=3;
 p1->ypos=30;
 Point *p2 = new Point;
 p2->xopos=70;
 p2->ypos=7;
 Point &pref=PntAdder(*p1, *p2);
 cout<<pref.xpos<<\" \"<<pref.ypos<<endl;
 delete p1;
 delete p2;
 delete &pref;
 return 0;
}


일단 맨처음에 struct 선언하는부분에서 빨간줄이 뜨더라고..아무래도 struct선언이 잘못되서 에러가 부왘뜨는거같은데..
책에는 이대로 되있는데 이게 왜안되는거야..? ㅜㅜ c에서 malloc약간 완벽하지 않다보니 동적할당이 아직은 잘이해가안되네
포인터는 이제슬슬 감이 잡힐려는데 말이야
형들도와줘