+ 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 Antworten
+ 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