C++ the program should be develop in Visual studio Program Requirements: Create
ID: 3924489 • Letter: C
Question
C++ the program should be develop in Visual studio
Program Requirements:
Create a class (to be named IntegerList), to hold integers. Use dynamic memory allocation (smart pointers) for handling any number of integers at run-time (read the integers until 0 is entered). The member data elements should be private with public member functions to handle the following operations:
Constructors
- one with no parameters to initialize the class to zero
- one with a pointer to an integer as parameter to initialize the class to contain a copy of the integer
Add function (Extend) to allow the adding an integer at the end of the list
Print function (PrintNum) to display the integers in the List on the standard output
Count function (CountNum) to return the number of integers stored in the list
Sort function (SortNum) to arrange the integers (use Bubble sort) in the list from smallest to largest
Explanation / Answer
#include<conio.h>
#include<iostream.h>
class integerlist
{
int a[n];
public:
void addfunc()
{
cin>>n;
if(n>0)
{
n=n+1;
}
}
void printfunc()
{
int i;
for(i=0;i<n;i++)
{
cout<<a[i]<<endl;
}
}
void countfunc()
{
cout<<n;
void sortfunc();
{
int i,temp,j;
for(i=0;i<n;i++)
{
if(a[i]>a[i+1])
{
temp = [i];
a[i] = a[i+1];
a[i+1] = temp;
}
}
}
void main()
{
integerlist t;
t.addfunc();
t.printfunc();
t.countfunc();
t.sortfunc();
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.