Created
November 17, 2009 16:00
-
-
Save kybernetyk/237011 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
class Vector2D | |
{ | |
public: | |
int getX (void); | |
void setX (int _x); | |
Vector2D (); | |
~Vector2D (); | |
private: | |
int x; | |
}; | |
Vector2D::Vector2D () | |
{ | |
} | |
Vector2D::~Vector2D () | |
{ | |
} | |
int Vector2D::getX (void) | |
{ | |
return x; | |
} | |
void Vector2D::setX (int _x) | |
{ | |
x = _x; | |
} | |
int main (int argc, const char * argv[]) | |
{ | |
// insert code here... | |
printf("Hello, World!\n"); | |
std::vector <Vector2D> array; | |
Vector2D myVec; | |
myVec.setX(12); | |
array.push_back (myVec); | |
std::vector <Vector2D>::iterator it = array.begin(); | |
while (it != array.end()) | |
{ | |
//referenz | |
Vector2D &myVec = *it; | |
//direkt objekt cast | |
//Vector2D myVec = (Vector2D)(*it); | |
printf("des vektors x: %i\n",myVec.getX()); | |
it ++; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment