+ 11
What you think about this?? Is it run successfully or not??if yes or no then why??lets clear basicsđđ
#include <iostream> using namespace std; int main() { void x=10; cout<<x; return 0; } https://code.sololearn.com/ccOe4o8nUhcx/?ref=app
16 Respostas
+ 8
why is anyone think that is this compile?
+ 7
share what you think and why about this ??
+ 7
@Deepak Gautam
đđđđ
đđ
+ 6
@sayan chandra
đđ
+ 5
@Willz
it is not matter what you assign to x it is focused on void anyway thank you for your answer
đđđ
+ 3
u can not declare a variable as void...
a variable must be of a legitimate type..
like int..float...double...char...or array type etc...
void is a return type
a return type goes only with a function...that has a possibility to return a value or charecter...or null..or an adress...or an array..or even the function itself...
so...
void x is an error..
+ 3
void isn't a datatype. it's a function.[this part is wrong]
+ 3
@sayan I wasn't referencing your answer. đ€đ
+ 2
void can only work as a return type because some functions don't need to return anything. Storing a void or empty value doesn't make any sence.
+ 2
wait brother...
i didnt say void is a data type..
i said void is a return type of a func.
its not a function
void means...
the function doesnt returns anything...
it suggests that only..
+ 2
ââ
+ 2
The same thing.. but thanks
+ 1
Youâre literally allocating the value of x to 0 , thanks to the âvoidâ return type you put there.
You should type in âintâ as in integer at the beginning of your variable (x = 10) if you really want your âxâ to be equal to â10â....
(laughs)
+ 1
Donât worry.. Iâve already predicted what would happen if I do that @Deepak Gautam
+ 1
Hola
+ 1
Hello