Saturday, January 1, 2011

C++ User Data Types

#include


using namespace std;

struct myData {

int x;
int y;

};

void print_userData(myData mD2) {
cout << "[" << mD2.x << "," << mD2.y << "]" << endl;

};


int main () {

myData mD;
mD.x = 5;
mD.y = 2;

myData *ptr;
ptr = &mD;

print_userData(mD);
print_userData(*ptr);
cout << "[" << mD.x << "," << mD.y << "]" << endl;
cout << "[" << (*ptr).x << "," << (*ptr).y << "]" << endl;
cout << "[" <<>x << "," <<>y << "]" << endl;



return 0;
}

No comments:

Post a Comment