Question
I have to write a program specific to the tasks stated in the code and then debug any issues. I've been having some difficulty with
I have to write a program specific to the tasks stated in the code and then debug any issues. I've been having some difficulty with this and any assistance would be greatly appreicated.
Question 1.
#ifndef VECTOR_HPP
#define VECTOR_HPP
class Vector { public: Vector() // default constructor sets size to 0 { }
Vector(int s) // makes size = s, //allocates s space, // makes all entries 0 { }
Vector(const Vector & rhs) // copy constructor // makes self a deep copy of rhs { } Vector operator = (const Vector & rhs) // makes self a deep copy of rhs { return *this; } ~Vector() // default destructor { } v
oid print() // Prints out the vector { }
void set(int val, int pos) // if 0
int main() { Vector a, b(3), c(3) ; int value; a.print(); // outputs [] b.print(); // outputs [ 0 0 0 ] c.set(1,0); c.set(2,1); c.set(3,2); c.print(); // outputs [ 1 2 3 ] Vector d(c); d.print(); // outputs [ 1 2 3 ] a = c; a.print(); return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started