Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Vector
#include <iostream> #include <vector> class Vector { public: explicit Vector () : x_{0}, y_{0}, z_{0} {} explicit Vector (double x, double y, double z) : x_{x}, y_{y}, z_{z} {} void print_vector () { std::cout << x_ << " " << y_ << " " << z_ << std::endl; } ~Vector() {} Vector (const Vector& vec) { x_ = vec.x_; y_ = vec.y_; z_ = vec.z_; } Vector& operator= (const Vector& vec) { x_ = vec.x_; y_ = vec.y_; z_ = vec.z_; } private: double x_; double y_; double z_; }; int main() { Vector w; Vector v {1.5, 2.5, 3.5}; w = v; // copy assignement Vector u (v); // copy constructor v.print_vector(); w.print_vector(); u.print_vector(); }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
PLoshtina na krug
Vector+Memory_Adv_C++_Tutorial
Vec+Mem+Adv_11
Volume of Sphere with Powf
多态
myfirst.cpp
Vectors as Inputs to Map
aa
Why C++ optimizer has problems with these temporary variables
Certificate Printing
Please log in to post a comment.