Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Operators in C++ what does (::Type*)0 mean

Tags:

c++

Can anyone tell me what this means?

(::Type*)0

actually it is part of this

return (is_modifytype()) ?
u.myfunction : (::Type*)0; 
like image 825
Billal Ouali Avatar asked May 22 '19 15:05

Billal Ouali


People also ask

What is the * operator and what does it do?

Multiplication * (Asterisk) Basic arithmetic operator used for multiplication; the result of an arithmetic operator is usually a numeric value. Division / Basic arithmetic operator used for division; the result of an arithmetic operator is usually a numeric value.

What does 0 mean in programming?

Zero is the lowest unsigned integer value, one of the most fundamental types in programming and hardware design. In computer science, zero is thus often used as the base case for many kinds of numerical recursion.

What is the value of 0 in C?

~0 is 0xffffffff, which is the binary representation of -1.


1 Answers

It means "cast the integer 0 (using a C-style cast) to the type Trip* (Trip pointer) found in the global namespace (::)".

It should just use nullptr - as in

return is_modifyCurrentTrip() ?
    u.modifyCurrentTrip : nullptr; 

Note: using :: explicitly to designate the global namespace prevents the compiler from prepending any namespace names itself - this is completely irrelevant when just using nullptr though.

like image 128
Jesper Juhl Avatar answered Oct 21 '22 13:10

Jesper Juhl