Created
March 18, 2015 02:37
-
-
Save BenMcH/01fdfb125cef285598e6 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 <iostream> | |
#include "Vector2.h" | |
int main(){ | |
Vector2 vec(2,4); | |
vec.printVector(); | |
system("pause"); | |
return 0; | |
} |
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 "Vector2.h" | |
#include <iostream> | |
Vector2::Vector2(){ | |
this->x = 0; | |
this->y = 0; | |
} | |
Vector2::Vector2(float x, float y){ | |
this->x = x; | |
this->y = y; | |
} | |
Vector2::~Vector2(){ | |
this->x = 0; | |
this->y = 0; | |
} | |
float Vector2::getX() const{ | |
return this->x; | |
} | |
float Vector2::getY() const{ | |
return this->y; | |
} | |
void Vector2::setX(float x){ | |
this->x = x; | |
} | |
void Vector2::setY(float y){ | |
this->y = y; | |
} | |
void Vector2::printVector() const{ | |
std::cout << "X: " << this->getX() << " Y: " << this->getY() << std::endl; | |
} |
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
#pragma once | |
class Vector2{ | |
public: | |
Vector2(); | |
Vector2(float x, float y); | |
virtual ~Vector2(); | |
void setX(float x); | |
void setY(float y); | |
float getX() const; | |
float getY() const; | |
void printVector() const; | |
private: | |
float x, y; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment