c_-_c_arrays:array_of_objects

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
c_-_c_arrays:array_of_objects [2020/04/15 08:18] – created peterc_-_c_arrays:array_of_objects [2020/07/15 09:30] (current) – external edit 127.0.0.1
Line 1: Line 1:
-x+====== C - C++ Arrays - Array of objects ====== 
 + 
 +<code cpp> 
 +#include <iostream>  
 +using namespace std;  
 +   
 +class forgetcode  
 +{     
 +public: 
 +  string str[5]; 
 + 
 +  void getlanguage(string a) 
 +  { 
 +    static int s=0; 
 +    str[s]=a; 
 +    s++; 
 +  }  
 + 
 +  void putlanguage() 
 +  { 
 +    static int i=0; 
 +       
 +    cout<<"\n"<<str[i]; 
 +    i++; 
 +  } 
 +}; 
 + 
 + 
 +int main()  
 +{  
 +  forgetcode f[5]; 
 +  string s[5]={"c","c++","java","javascript","c#"}; 
 + 
 +  for(int i=0; i < 5; i++)  
 +    f[i].getlanguage(s[i]); 
 + 
 +  for(int i=0; i < 5; i++)  
 +    f[i].putlanguage();  
 + 
 +  return 0;  
 +
 +</code> 
c_-_c_arrays/array_of_objects.1586938726.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki