Last active
May 15, 2020 15:14
-
-
Save parthibx24/51d718747375c5560aa6b39367324b45 to your computer and use it in GitHub Desktop.
method chaining in c. definitely not c a n c e r .
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 <stdio.h> | |
| /* not good way | |
| typedef struct dk { | |
| void (* setbro) (int); | |
| int watbro; | |
| } dk; | |
| typedef struct { | |
| dk (* setbro) (int); | |
| int watbro; | |
| } nn; */ | |
| /* kinda good way 1 *\/ | |
| typedef struct gStruct { | |
| struct gStruct (* setbro) (int); | |
| int watbro; | |
| } nn; */ | |
| /* kinda good way 2 *\/ | |
| struct gStruct { | |
| struct gStruct (* setbro) (int); | |
| int watbro; | |
| }; */ | |
| /* kinda good way 3 */ | |
| typedef struct nn { | |
| struct nn (* setbro) (int); | |
| int watbro; | |
| } nn; | |
| /* prolly not kinda good way 4 *\/ | |
| struct mango { | |
| struct mango (* setbro) (int); | |
| int watbro; | |
| } nnno = {}; | |
| typedef struct nnno nn; */ | |
| nn pp; | |
| nn bruh(int i) { | |
| pp.watbro = i; | |
| return pp; | |
| } | |
| nn kk() { | |
| pp.setbro = &bruh; | |
| return pp; | |
| } | |
| int main() | |
| { | |
| printf("Hello World %d", | |
| kk() | |
| .setbro(69) | |
| .watbro); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment