Site gidip geliyor, şuan açık.
#include <iostream>
using namespace std;
void GetXY(int * xy)
{
xy[0] = 5;
xy[1] = 10;
}
int main()
{
int xy[2];
GetXY((int*)xy);
cout << xy[0] << "n";
cout << xy[1];
return 0;
}
Yok hocam bu değil yapmak istediğim yine de teşekkürler
Aşağıdaki şekilde yapabilirsiniz:
struct Coordinate {
int x, y;
};
class test
{
private:
Coordinate coordinate;
public:
void setX(int x) { coordinate.x = x; };
void setY(int y) { coordinate.y = y; };
void setXY(int x, int y) { coordinate = { x,y }; };
int getX() { return coordinate.x; };
int getY() { return coordinate.y; };
Coordinate getXY() { return coordinate; };
};Test için:
#include "test.h"
...
void main(){
test t;
t.setX(10);
t.setY(11);
std::cout << "X:" << t.getX() << std::endl;
std::cout << "Y:" << t.getY() << std::endl;
std::cout << "X and Y : " << t.getXY().x << "," << t.getXY().y<<std::endl;
}
Hocam çok çok çok teşekkür ederim ama bunu diziler ile gösterseniz ? Kaynak kod kısımlarını şöyle göndereyim altada siz ordan düzenlerseniz kolayınıza gelir. Çok teşekkür ederim.
MyPoint.h
#include <iostream>
#ifndef MYPOINT_H
#define MYPOINT_H
class MyPoint
{
public:
MyPoint();
MyPoint(int,int);
int getX();
void setX(int);
int getY();
void setY(int);
int getXY();
void setXY(int,int);
void toString();
double distance(int,int);
double distance();
private:
int x;
int y;
int a;
int b;
};
#endif
MyPoint.cpp
#include "MyPoint.h"
#include <iostream>
#include <math.h>
MyPoint::MyPoint() {
x = 0;
y = 0;
coordinate.q=x;
coordinate.w=y;
}
MyPoint::MyPoint(int a, int b) {
x = a;
y = b;
}
int MyPoint::getX(){
return x;
}
void MyPoint::setX(int a){
x=a;
}
int MyPoint::getY(){
return y;
}
void MyPoint::setY(int a){
y=a;
}
int MyPoint::getXY(){
}
void MyPoint::setXY(int a,int b){
x = a;
y = b;
}
void MyPoint::toString(){
cout << "Nokta kordinatınız : (" << x << "," << y << ")" << endl;
}
double MyPoint::distance(int a, int b){
return sqrt((x-a)*(x-a)+(y-b)*(y-b));
}
double MyPoint::distance(){
return sqrt((x)*(x)+(y)*(y));
}