0
So in this instance I'm confused. We're voiding the int x but then in the last part we say int main and our output is x.
#include <iostream> using namespace std; void printSomething(int x) { cout << x; } int main() { printSomething(42); } I'm in need of clarification because I think we're voiding the int but then we bring it back and get 42. I'm just confused on what is happening here
1 ответ
+ 2
When you use void, you’re saying that the method does not return anything (you’re not returning x, just printing.) Cout is used to print text to the console. Printing text and returning a value are not the same. Returning a value does not automatically print it.