c_-_c_arrays:array_of_objects
C - C++ Arrays - Array of objects
#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; }
c_-_c_arrays/array_of_objects.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1