以下代码打印:
2
1
代替
2
2
为什么我的设置器没有调整值?
主要的
Vector location = camera.get_location();
camera.get_location().set_y(location.get_y() + 1);
std::cout << location.get_y() + 1 << std::endl;
std::cout << camera.get_location().get_y() << std::endl;
相机.h
#ifndef CAMERA_H
#define CAMERA_H
#include "vector.h"
class Camera {
private:
Vector location;
public:
Vector get_location();
void set_location(Vector);
};
#endif
相机.cpp
#include "camera.h"
Vector Camera::get_location() { return location; }
void Camera::set_location(Vector l) { location = l; }