c_-_c_arrays:array_of_objects
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
c_-_c_arrays:array_of_objects [2020/04/15 08:18] – created peter | c_-_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 < | ||
+ | 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<<" | ||
+ | i++; | ||
+ | } | ||
+ | }; | ||
+ | |||
+ | |||
+ | int main() | ||
+ | { | ||
+ | forgetcode f[5]; | ||
+ | string s[5]={" | ||
+ | |||
+ | 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.1586938726.txt.gz · Last modified: 2020/07/15 09:30 (external edit)