Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "c.h"
- c::c() {
- this->v = new int[2];
- }
- c::c(c const& other) {
- this->v = new int[2];
- for (size_t index = 0; index < 2; index++) {
- this->v[index] = other.v[index];
- }
- }
- c& c::operator=(c const& other) {
- delete [] this->v;
- this->v = new int[2];
- for (size_t index = 0; index < 2; index++) {
- this->v[index] = other.v[index];
- }
- return *this;
- }
- //header:
- #ifndef C_H
- #define C_H
- struct c {
- private:
- int *v;
- public:
- c();
- c(c const& other);
- c& operator=(c const& other);
- };
- #endif // C_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement