Created
April 7, 2020 18:01
-
-
Save mjcarroll/b4c04c1f92d5b7362d11851bd442ff91 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 "Point.h" | |
int main(int argc, char** argv) | |
{ | |
Point p; | |
} |
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 "Point_build.h" | |
int main(int argc, char** argv) | |
{ | |
auto p = Point::build().set_x(0.0).set_y(0.0).set_z(0.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
#ifndef POINT_H_ | |
#define POINT_H_ | |
class Point | |
{ | |
public: | |
class build; | |
double x; | |
double y; | |
double z; | |
}; | |
#endif |
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
#ifndef POINT_BUILD_H_ | |
#define POINT_BUILD_H_ | |
#include "Point.h" | |
#include <utility> | |
class Init_Point_Z | |
{ | |
public: | |
explicit | |
Init_Point_Z(const Point& msg) : msg_(msg) {} | |
Point | |
set_z(double val) | |
{ | |
msg_.z = std::move(val); | |
return std::move(msg_); | |
} | |
private: | |
Point msg_; | |
}; | |
class Init_Point_Y | |
{ | |
public: | |
explicit | |
Init_Point_Y(const Point& msg) : msg_(msg) {} | |
Init_Point_Z | |
set_y(double val) | |
{ | |
msg_.y = std::move(val); | |
return Init_Point_Z(msg_); | |
} | |
private: | |
Point msg_; | |
}; | |
class Point::build | |
{ | |
public: | |
build(){} | |
Init_Point_Y | |
set_x(double val) | |
{ | |
msg_.x = std::move(val); | |
return Init_Point_Y(msg_); | |
} | |
private: | |
Point msg_; | |
}; | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment