feat: implement CPP07 C++20 card
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
#include <iostream>
|
||||
struct Member { Member() { std::cout << "member\n"; } };
|
||||
struct Object { Member member; Object() { std::cout << "object\n"; } };
|
||||
int main() { Object object; (void)object; std::cout << "ready\n"; }
|
||||
@@ -0,0 +1,4 @@
|
||||
#include <iostream>
|
||||
struct Trace { const char* name; explicit Trace(const char* value) : name{value} { std::cout << "construct=" << name << '\n'; } ~Trace() { std::cout << "destroy=" << name << '\n'; } };
|
||||
void scope() { Trace first{"A"}; Trace second{"B"}; }
|
||||
int main() { std::cout << "enter\n"; scope(); std::cout << "leave\n"; }
|
||||
@@ -0,0 +1,3 @@
|
||||
#include <iostream>
|
||||
class Point { public: Point() : Point{0, 0} {} Point(int x, int y) : x_{x}, y_{y} {} int x() const { return x_; } int y() const { return y_; } private: int x_; int y_; };
|
||||
int main() { Point point; Point other{3, 4}; std::cout << "point=" << point.x() << ',' << point.y() << " other=" << other.x() << ',' << other.y() << '\n'; }
|
||||
Reference in New Issue
Block a user