Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Header File Definition - override C++ vector definition #ifndef VECTOR_H #define VECTOR_H class Vector { public: Vector (): Vector (int s); Vector (const Vector
Header File Definition - override C++ vector definition #ifndef VECTOR_H #define VECTOR_H class Vector { public: Vector (): Vector (int s); Vector (const Vector & other); ~Vector (); void print(); void set( int val, int pos); // default constructor // makes size = s, //allocates s space, // makes all entries 0 // copy constructor // makes a deep copy // default destructor // Prints out the vector // if 0 { Write methods defined in header file and use the following "stub" Main to test header file #include "Vector.h" #include int main() Vector a, b(3), c(3); // outputs [] // outputs [000] //output error message a.print(); b.print(); c.set(0,-1); c.set(1,0); c.set(2,1); c.set(3,2); c.set(4,3) // outputs error message c.print(); // outputs [123] Vector d(c); d.print(); // outputs [123] d.set(0,1); d.print(); // outputs [103] 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