+ 1

Kто нибудь понимает как это работает ?

#include <iostream> #include <cmath> using namespace std; struct S { S(){print('s');} void print(char c){ cout<<c; } }A; int main() { S a; a.print('I'); //Output ssI }

14th Apr 2019, 7:55 PM
San Anemos
San Anemos - avatar
2 ответов
+ 1
The struct variable A. Prints the first 's'' S a; prints the second 's' a.print. prints the I Actually when having a struct variable like 'A' you do not need to declare the struct. A.print('B'); Will print sB Having a struct variable is optional. https://code.sololearn.com/cAydgPV910w1/?ref=app https://www.tutorialspoint.com/cplusplus/cpp_data_structures.htm
14th Apr 2019, 9:42 PM
sneeze
sneeze - avatar
+ 2
Thanks
14th Apr 2019, 9:43 PM
San Anemos
San Anemos - avatar