Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- //////////////////////////////// struct
- class CMonth
- {
- public:
- char sz[19];
- int nDays;
- //////////////////
- void foo()
- {
- nDays = 1130;
- }
- ///////////////////
- char* foo2();
- };
- ////////////////////////////////////////////////////
- int main() //
- {
- CMonth Cn;
- Cn.foo ();
- Cn.foo2();
- //foo2()
- printf("%s nDays = %d\n", Cn.sz, Cn.nDays);
- }
- char* CMonth::foo2()
- {
- strcpy(sz, "May");
- return sz;
- }
- /*
- #include <stdio.h>
- //////////////////////////////// struct
- class CMonth
- {
- char sz[19];
- public:
- int nDays;
- void foo()
- {
- nDays = 1130;
- }
- };
- ////////////////////////////////////////////////////
- int main() //
- {
- CMonth Cn;
- Cn.foo();
- printf("nDays = %d\n", Cn.nDays);
- }
- */
- /*
- #include <stdio.h>
- ////////////////////////////////
- struct CMonth
- {
- char sz[19];
- int nDays;
- };
- void foo(CMonth *p);
- ////////////////////////////////////////////////////
- int main() //
- {
- CMonth mArr[14];
- foo(mArr);
- printf("January = %d\n", mArr[1].nDays);
- printf("February = %d\n", mArr[2].nDays);
- printf("March = %d\n", mArr[3].nDays);
- }
- ////////////////////////////////////////////////////
- void foo(CMonth *p)
- {
- p = p + 1; //[1].nDays = 11131;
- CMonth &a = *p;
- a.nDays = 4444;
- //--------------
- p += 1;
- p->nDays = 29;
- //--------------
- p ++;
- (*p).nDays = 31;
- }
- */
- /*
- #include <stdio.h>
- ////////////////////////////////
- struct CMonth
- {
- char sz[19];
- int nDays;
- };
- void foo(CMonth *p);
- ////////////////////////////////////////////////////
- int main() //
- {
- CMonth mArr[14];
- foo(mArr);
- printf("%d\n", mArr[1].nDays);
- }
- ////////////////////////////////////////////////////
- void foo(CMonth *p)
- {
- p[1].nDays = 11131;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement