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
int divide by int
water drop/ water land
replace_copy-30-Seconds-of-C++
Best way for getting more precision no.
MAC
gal
same
lambda demo
Count squares
teste