Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Primitive types as objects in c++

Tags:

I have come across the following piece of code and i couldn't understand what it means:

typedef int INT;  5 .INT::~INT(); 

Note: There is a space between the numeric 5 and decimal.

Questions: 1. Could somebody explain what exactly does the two lines above mean? 2. Why would it not work without typedef? Any reason behind it?5 .int::~int() throws error.

like image 795
anurag86 Avatar asked Sep 19 '15 13:09

anurag86


People also ask

Can primitive data types be used as objects?

The language defines eight Java primitive data types: boolean, float, double, byte, short, int, long and char. These eight Java primitive data types fall into the category of things that aren't objects.

What are primitive objects in C?

New object types can be constructed using existing object types, but at the lowest level there are some built-in object types called primitives. These include: C integers: byte (equivalent to C's char), short, int, long, long long and unsigned equivalents. C floats: float, double and long double.

What is primitive data type in Objective C?

There are two primitive floating point types available in Objective-C: The float type is a 32-bit single precision float point value that uses a single sign bit, an 8-bit mantissa and 23 bits of exponent when storing numbers.

What is primitive type and object type?

primitive types are immutable, objects only have an immutable reference, but their value can change over time. primitive types are passed by value. Objects are passed by reference. primitive types are copied by value. Objects are copied by reference.


1 Answers

.INT::~INT() is a pseudo destructor call, useful for templated code.

Note that it can't be used without the typedef type.


Standardese:

C++03 §5.2.4 “Pseudo destructor call”:
  1. The use of a pseudo-destructor-name after a dot . or arrow -> operator represents the destructor for the non-class type named by type-name. The result shall only be used as the operand for the function call operator (), and the result of such a call has type void. The only effect is the evaluation of the postfix-expression before the dot or arrow.
like image 104
Cheers and hth. - Alf Avatar answered Oct 16 '22 03:10

Cheers and hth. - Alf