Skip to content

Instantly share code, notes, and snippets.

@BenMcH
Created March 18, 2015 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMcH/01fdfb125cef285598e6 to your computer and use it in GitHub Desktop.
Save BenMcH/01fdfb125cef285598e6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include "Vector2.h"
int main(){
Vector2 vec(2,4);
vec.printVector();
system("pause");
return 0;
}
#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;
}
#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