Goal
I want to know if there is a 'null' in C++, just like how there is None
in Python or a nil
in Ruby. I also want to know how you should use it.
Code
Here is my C++ code I made.
#include <iostream>
int main()
{
bool value = _____; // Are you supposed to use 'null' with a 'bool' type?
std::cout << value;
}
Attemps
I tried replacing _____
with null
, nil
, Null
, and Nil
, but none of them worked! I even tried to replace _____
with none
and None
, but all I got was this error message (not complete error message):
main.cpp: In function 'int main()':
main.cpp:5:16: error: 'None' was not declared in this scope
The website Repl.it even suggested to change None
into clone
. Should I?
main.cpp:5:16: note: suggested alternative: 'clone'
So how do you have 'null' fit into a variable, but is there even a 'null' in C++?