Problems with constructors and destructors

Hi I'm having trouble with this program I am trying to create, I was giving a set of code for int main, but I am suppose to create a class with constructors and destructors but I am stuck on some parts and I do not know where to go from here. Usually I try to do this on my own, but I am lost on this and this is my first time posting on this site.

-I had to create a private data member with int num[10].
-public variable static int loc initially zero.
-Public constructor with class Store and sets num to -1.
-create a destructor that displays that num is empty
-a member function insert(int item) that wehn invoked in Store, inserts value passed to item into array num.
-Member function remove(int val) when invoked, removes all val in array num.
-Static member function contents that if invoked displays how many values currently stored.

This is the coding I have so far!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
  #include <iostream>

using namespace std;

class Store{
      private:
        int num[10];

	  public:
             Store(){
             for (int i = 0; i<10; i++){
                 num[i] = -1;
             }
             }
  	      static int loc;
		~Store(void)
		{
         cout<<"Destructor invoked for Store when called : " <<num<<endl;
         }
        void insert(int item)
         {
         cout<<"the value of num is : " <<item << endl;
         }
};

int main()
{
    
    cout<<"Invoking process:\n\n";
    Store process(); 
    cout<<"Returned from process()\n\n";
	Store sobj;
	int resp;
    int Val;
	cout<<"Type 1 to insert, 2 to remove, 3 to see how many items in the store, 4 to display store's contents, 5 to quit. ";
	cin>>resp;
	switch(resp){
                 case 1: cout<<"Enter a value to insert.... "; break;
                 case 2: cout<<"Enter a value to remove.... "; break;
                 case 3: cout<<"Number in store = " <<Store::loc<< endl; break;
                 case 4: Store::Contents();break;
                 }

	system("PAUSE");
	
}
Last edited on
Topic archived. No new replies allowed.