Helppp..!In this please

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
#include<iostream>
using namespace std;
template<class myType>
class myArray{
      public:
      myType *array;
      int num;
             myArray(int num,int num2){
                         int k=0;
                         k=num2-num;
                         array=new myType[k];
                         for(int i=num;i<num2;i++)
                         {
                                 cout<<"Enter "<<i+1<<"th element:";
                                 cin>>array[i];
                         
                                 }
                       }            
                       
      };

int main()
{
   
   myArray<string> obj2(5,12);
    
    for(int i=5;i<12;i++)
    {
            cout<<i+1<<" is"<<obj2.array[i]<<endl;
            }
    
    
    cout<<endl;
    system("pause");   
    return 0;
}

In the above program in the line eleven if i comment it the program is runnning properly for int and double, but if I write the line eleven it will still working for char but not for int and float. The problem is that some how the program is working for int,double and char but why not for string in either cases?
Topic archived. No new replies allowed.