How to solve this Problem in C++


//set.h
#include<iostream>
using namespace std;
template<typename T>
class set{
private:
T *arr;
int size;
public:
set(int capacity){
arr = new
T[capacity];
size = 0;
}
~set(){
delete []
arr;
size = 0;
}
void add(T data){
cout<<"
Adding : "<<data<<endl;
int i;
for(i=0;i<size;i++){
if(arr[i] == data) break;
}
if(i==size)arr[size++] = data;
}
int getCount(){
return
size;
}
T* getArray(){
return
arr;
}
};
//main.cpp
#include "set.h"
int main(){
set<int> set1(10);
set<double> set2(10);
set<string> set3(10);
cout<<"--------------------------------\n";
cout<<"---Example 1: Set of
integers---\n";
cout<<"--------------------------------\n";
set1.add(10);
set1.add(5);
set1.add(15);
set1.add(25);
set1.add(15);
cout<<"--------------------------------\n\n";
cout<<"The first set has
"<<set1.getCount()<<" items\nThe are: \n";
for(int i=0;i<set1.getCount();i++){
cout<<"\t"<<set1.getArray()[i]<<"\n";
}
cout<<"\n--------------------------------\n";
cout<<"---Example 2: Set of doubles---\n";
cout<<"--------------------------------\n";
set2.add(1.5);
set2.add(5.6);
set2.add(12.8);
set2.add(1.5);
set2.add(12.8);
cout<<"--------------------------------\n\n";
cout<<"The second set has
"<<set2.getCount()<<" items\nThe are: \n";
for(int i=0;i<set2.getCount();i++){
cout<<"\t"<<set2.getArray()[i]<<"\n";
}
cout<<"\n--------------------------------\n";
cout<<"---Example 3: Set of strings---\n";
cout<<"--------------------------------\n";
set3.add("John Smith");
set3.add("Jane doe");
set3.add("John Smith");
set3.add("Jack black");
cout<<"--------------------------------\n\n";
cout<<"The third set has
"<<set3.getCount()<<" items\nThe are: \n";
for(int i=0;i<set3.getCount();i++){
cout<<"\t"<<set3.getArray()[i]<<"\n";
}
return 0;
}
//sample output

How to solve this Problem in C++ . The Problem Write program that uses a class...
Please write below code in C++ using Visual
Studio.
Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 • Hint: Use vectors and vector functions to store the set of items 2. Get the number of items in the...
Write a program in C++ that uses a class template to create a
set of items.
. . The Problem Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 Hint: Use vectors and vector functions to store the set of...
what would be the solution code to this problem in c++?
The Problem Write program that uses a class template to create a set of items. The program should: 1. add items to the set (there shouldn't be any duplicates) • Example: if your codes is adding three integers, 10, 5, 10, then your program will add only two values 10 and 5 Hint: Use vectors and vector functions to store the set of items 2. Get the number of...
In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....
(C++ exercise) 5. Write a new Checkbook class that uses a dynamic array. Call the class a different name, since it will be different from the latest version that uses a static array. Start off with a dynamic array size of 2, made by the constructor. Every time the dynamic array becomes full and a new check has to be written, double the current size of the array. Write a doubleArray function for the class to do this, but place...
Can someone help me with these C program problems? Thanks 1. Write a C program that creates two arrays of integers, one on the stack and one on the heap. You will loop through these arrays and populate them with values (any value is fine). You will then loop through these arrays again and print each value. Your output should look something like “Value in index 1 is 100 from stack array and 100 from heap array.” Do not forget...
C ++ 1. Write down the missing code according to the comments. #include <cstdlib> #include <iostream> using namespace std; void fun1(int radius) { /* dynamic memory management */ double * dmptr; double circumference; /* add the code below to: - allocate a memory location for a double and nameless variable in heap and assign its address to the pointer - assign 3.14 to the variable in heap via the pointer....
Write C++ program (studentsGpa.cpp) uses dynamic allocation to create an array of strings. It asks the user to enter a number and based on the entered number it allocates the array size. Then based on that number it asks the user that many times to enter student’s names. What you need to do: Add another array of doubles to store the gpa of each student as you enter them You need to display both the student’s name and...
Write a program that uses a vector to store a set of integers. The program outputs the smallest, largest, and average of the numbers. When declaring the numbers do not specify its size. Use the function push_back to insert elements into the array. You will have to declare the size of the vector somewhere in your program. *Note: I need help to write out this problem in C++ while using Visual Studio 2017
Write an object-oriented C++ program (i.e. a class and a main function to use it), using pointer variables, that program that performs specific searching and sorting exercises of an array of integers. This program has six required outputs. Start by initializing an array with the following integers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Your array input may be hardcoded...