Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "iostream"
- using namespace std;
- struct Point
- {
- double x,y;
- };
- void DoublePoint(Point* p);
- void Print(Point p);
- int main()
- {
- Point p1,p2;
- p1.x=9.78;
- p1.y=10.98;
- p2.x=99.01;
- p2.y=22.23;
- Print(p1);
- Print(p2);
- DoublePoint(&p1); //You pass the position of the variable so you have to type &var
- DoublePoint(&p2);
- Print(p1);
- Print(p2);
- system("PAUSE");
- }
- void DoublePoint(Point* p)
- {
- p->x=2*p->x; //With Pointers you have to use "->" instead of "." and you must not type "*" before the variable because
- p->y=2*p->y; //the program is using structures
- return;
- }
- void Print(Point p)
- {
- cout<<p.x<<' '<<p.y<<endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement