Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with this. Thanks a lot; Appreciate it. a) Implement member functions

ID: 3629193 • Letter: N

Question

Need help with this. Thanks a lot; Appreciate it.
a) Implement member functions in class Vec (its defined in Vec.h)
b) Define and implement operator function << to output data in class Vec
c) Define and implement operator function >> to input data in class Vec
d) Test your implementation with a small driver program (driver.cpp)

//Vec.h
const int CAPACITY=6;
typedef int ElemType;
class Vec
{
public:
Vec(); // intitalize the elements to 0
//return the element at position pos in myData
ElemType get(int pos) const;
//set the element at position pos to be val
void set(ElemType val, int pos);
// set the elements in this class to be equal to those in rh
const Vec & operator = (const Vec &rh);
//adding elements in op2 to the elements in this class
const Vec & operator+(const Vec & op2);
private:
ElemType myData[CAPACITY];
}

//driver.cpp
#include
#include
using namespace std;

int main()
{
Vec a,b,c;
cin>>a>>b;
c=a+b;
cout< }

Explanation / Answer

//vector.cpp
//vector class member
public vec::outputVector(const vector<int>&array)
{
size_t i;
for(i=0;i<array.size();i++)
{
cout<<setw(12)<<array[i];
}
}
//vector class member
public vec::inputVector(vector<int>&array)
{
size_t i;
for(i=0;i<array.size();i++)
{
cin>>array[i];
}
}

//DriverMain.cpp
//Header files
#include<iostream>
#include<iomanip.h>
using namespace std;
//main funtion
int main()
{
//size of first array
vector<int>integers1(2);
cout<<"input 2-elements"<<endl;
intputVector(integers1);
cout<<"the elements are"<<endl;
outputVector(integers1);
}

Hope this would help you

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote