For functions we should use brackets if only 1statement is in the body of function ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

For functions we should use brackets if only 1statement is in the body of function ??

example::int types(int x) { return x*5; }

23rd Aug 2018, 5:22 PM
Vamsikrishna Mummeneni
Vamsikrishna Mummeneni - avatar
3 Answers
+ 2
yea, even if only 1
23rd Aug 2018, 6:02 PM
Data
Data - avatar
+ 1
you can have one with empty body, its not really usefull tho unless its a virtual or a pure virtual function and you are working with polymorphism, then its useful
23rd Aug 2018, 6:08 PM
Data
Data - avatar
0
hi, Can't you have function with no body or nothing in the body ? function Myfunction () {}
23rd Aug 2018, 6:07 PM
S. Kaouche
S. Kaouche - avatar