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

Problem T. (20 pts total) Give a template for the program class Geom which consi

ID: 3801592 • Letter: P

Question

Problem T. (20 pts total) Give a template for the program class Geom which consists of a list (vector) of objects of type Point, Line, or Circle from the CWIN library. Your class should include a default constructor, mutator function add which adds an object TO THE END function pull which removes the object FROM THE FRONT of the list, a mutator objects in of the list and an accessor function show which displays all the and the list (output to CWIN. BE SURE to give BOTH the template class interface ALL functions.

Explanation / Answer

The following is your program. I don't have access to windows library. I'm into Linux. I have written code which will be useful for you to convert it into windows. Include the CWIN header and add your types. It will definitely work.

Code:

#include<iostream>
#include<string>
#include<vector>
#include<iterator>
using namespace std;

template <class T>
class Geom
{

vector<T> lst;

public:
Geom<T>(T lst);

T pull();
void add(T& ele);

void show();
};

template <class T>
Geom<T>::Geom(T l){
lst= vector<T>();
lst.push_back(l);
}

template <class T>
T Geom<T>::pull()
{
T ele=lst.front();
lst.erase(lst.begin());
return ele;
}

template <class T>
void Geom<T>::add(T& ele)
{
lst.push_back(ele);
}

template <class T>
void Geom<T>::show()
{

for(typename vector<T>::iterator itr=lst.begin(); itr!=lst.end();itr++)
cout<<*itr<<endl;
}

int main(void)
{

Geom<int> ab(2);

for(int j=4;j<10;j++)
   ab.add(j);

cout<<"Before pulling first element"<<endl;
ab.show();


int e=ab.pull();
cout<<"After pulling first element from vector"<<endl;
ab.show();
return 0;
}

Output:

Before pulling first element
2
4
5
6
7
8
9
After pulling first element from vector
4
5
6
7
8
9

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