Hi, I am just trying to check whether compiler allows type name as variable name. When i tried
int int;
It reported an error saying
error C2632: 'int' followed by 'int' is illegal
But when i tried
#include <string>
using namespace std;
int main()
{
string string;
}
It didn't give any error.
Both string
and int
are data types.
Why compiler allows string
and doesn't allow int
?
EDIT: includes updated.
EDIT: Some people are saying that int is not a class. In that case, why below line is allowed.
int a(10);
it works similar to constructor of a class.