Created
November 2, 2013 13:27
-
-
Save Zulqurnain/67935e6fe03d031e7aad to your computer and use it in GitHub Desktop.
Alternate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream.h> | |
| #include <string.h> | |
| class student | |
| { | |
| char *arr[5]; | |
| public: | |
| student(void){ | |
| for(int i=0;i<5;i++){ | |
| arr[i]=0; | |
| } | |
| } | |
| void setarr(char* p,int n) | |
| { | |
| if(arr[n]=='\0'){ | |
| arr[n]=new char [strlen(p)+1]; | |
| strcpy(arr[n],p); | |
| } | |
| } | |
| char* getarr(int i) | |
| { | |
| return arr[i]; | |
| } | |
| ~student(void){ | |
| for(int k=0;k<5;k++){ | |
| delete arr[k]; | |
| } | |
| } | |
| }; | |
| int main(){ // by Zulqurnain jutt | |
| student s1; | |
| char a1[100]; | |
| for(int i=0;i<5;i++){ | |
| cout<<"Enter Name"<<i<<" :=:"; cin>>a1; | |
| s1.setarr(a1,i); | |
| } | |
| for(i=0;i<5;i++){ | |
| cout<<s1.getarr(i); | |
| cout<<"\n"; | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment