+ 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

14th Mar 2018, 4:55 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
16 ответов
+ 8
why is anyone think that is this compile?
15th Mar 2018, 2:40 AM
Vukan
Vukan - avatar
+ 7
share what you think and why about this ??
14th Mar 2018, 5:01 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 7
@Deepak Gautam 😊😊🙄🙄 👌👌
14th Mar 2018, 5:45 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 6
@sayan chandra 😊😊
14th Mar 2018, 5:08 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 5
@Willz it is not matter what you assign to x it is focused on void anyway thank you for your answer 😊😊👍
14th Mar 2018, 7:16 PM
ASIF BILAKHIYA
ASIF BILAKHIYA - avatar
+ 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..
14th Mar 2018, 5:04 PM
sayan chandra
sayan chandra - avatar
+ 3
void isn't a datatype. it's a function.[this part is wrong]
14th Mar 2018, 5:05 PM
David Borges Reis e Silva
David Borges Reis e Silva - avatar
+ 3
@sayan I wasn't referencing your answer. 🤔🖖
14th Mar 2018, 5:09 PM
David Borges Reis e Silva
David Borges Reis e Silva - avatar
+ 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.
14th Mar 2018, 5:02 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 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..
14th Mar 2018, 5:07 PM
sayan chandra
sayan chandra - avatar
+ 2
✌✌
14th Mar 2018, 5:09 PM
sayan chandra
sayan chandra - avatar
+ 2
The same thing.. but thanks
14th Mar 2018, 8:02 PM
Willz
Willz  - avatar
+ 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)
14th Mar 2018, 7:11 PM
Willz
Willz  - avatar
+ 1
Don’t worry.. I’ve already predicted what would happen if I do that @Deepak Gautam
15th Mar 2018, 7:27 AM
Willz
Willz  - avatar
+ 1
Hola
16th Mar 2018, 2:03 AM
Edgar Cristaldo
Edgar Cristaldo - avatar
+ 1
Hello
21st Mar 2018, 2:57 PM
muniyappan
muniyappan - avatar