Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- class Vector{
- double x;
- double y;
- public:
- Vector();
- Vector(double, double);
- void print();
- double abs();
- };
- Vector::Vector(double x, double y){
- this->x=x;
- this->y=y;
- }
- Vector::Vector(){
- cin >> x >> y;
- }
- void Vector::print(){
- cout << "(" << x << "," << y << ")" << endl;;
- }
- double Vector::abs(){
- return sqrt(x*x+y*y);
- }
- int main(int argc, char** argv) {
- // Vector *v = new Vector(1,2); // konstruktoros obj letrehozas
- Vector *v = new Vector(); //obj letrehozas
- v -> print(); // fuggvenyhivas
- cout << v -> abs(); // kiiratni az absz erteket
- delete v; // memoria felszabaditas
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement