Run Code
|
API
|
Code Wall
|
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
Stream5
pi with cmath
Default_Template
Binary Search
Comp Conexe
const example
Guess Number
informatika / Cinta Avrille X MIPA 5
designated-inits
TempQuickDoubArray2