+ 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 }
2 Respuestas
+ 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
+ 2
Thanks