xtd 1.0.0
Loading...
Searching...
No Matches
self.cpp

demonstrates how to use self_ keyword.

#include <xtd/xtd>
struct point {
int x = 0;
int y = 0;
auto offset(int x, int y) noexcept -> point& {
self_.x += x;
self_.y += y;
return self_;
}
auto to_string() const noexcept -> string {return "point {x="_s + x + ", y=" + y + "}";}
};
auto main() -> int {
auto c = point {.x = 200, .y = 100};
println("c => " + c);
println("offset");
println("c => " + c.offset(50, 20));
}
// This code can produce the following output :
//
// c => point {x=200, y=100}
// offset
// c => point {x=250, y=120}
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
@ c
The C key.
Definition console_key.hpp:92
auto println(FILE *file) -> void
Writes the current line terminator to the file output stream using the specified format information.
Definition println.hpp:15