0
Can we declare integer as data type?
int x=0; //ok integer x=0; // right or wrong? see the 2nd comment and ans it?
12 Respuestas
+ 7
No, you can't declare an integer data type. Int means Integer Data type.
+ 5
There an option you can define an integer as an int. You just wanted use integer in place of an int so you can define it.
Just use #define integer int
This will let you declare a variable with integer keyword.
https://code.sololearn.com/cRg2HlPmzTPz/#cpp
+ 3
no u cant declare integer as data type bcz integer is wrapper class
U can use integer as like dis
int a= Integer.parseInt(x);//as Integer.parseInt is a method
hope u get it
+ 2
Here's C++ example because it needed some messing around:
https://code.sololearn.com/c8Er55KM8x8T/?ref=app
+ 1
when we right integer then program works or not?
+ 1
try yourself
+ 1
Rahul Bavannavar no it did not work if u use integer it cause error as Integer is wrapper class
+ 1
I Know this ans bro...it's question regarding interview
+ 1
You can do it in some cases.
In Java, Integer x = 0; would work because it will be automatically converted to Integer type. In fact, it's more efficient than Integer x = new Integer(0);
In C++, you can make integer class and overload operators to convert to int and make single parameter constructor, then your code will be correct.
+ 1
sometimes. example: int and Int32 mean the same thing in C#
0
integer is not a data type.
0
Rahul Bavannavar what do u mean with question regarding interview????