Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » BeginnersRSS Feeds

Template based array input

Posted By: Adelberto Fischer     Category: C++ Programming     Views: 3262

Template based array input.

Code for Template based array input in C++ Programming

# include <iostream.h>
# include <conio.h>

template <class T>
void acc(T a)
{
    T *v;
   cout<<"\n ENTER THE LIMIT OF THE ARRAY:->";
   int n;
   cin>>n;
   v=new T[n];
   cout<<"\n ENTER THE VALUES IN IT:->";
   for(int i=0;i<n;i++){
          cin>>v[i];
   }
   cout<<endl<<endl;
   for(int i=0;i<n;i++)
       cout<<v[i]<<" ";
   getch();
}

void main()
{
    acc(1);
   getch();
}
  
Share: 


Didn't find what you were looking for? Find more on Template based array input Or get search suggestion and latest updates.

Adelberto Fischer
Adelberto Fischer author of Template based array input is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!