function returning bool works even though it returns 1 or 0

Kaushik Reddy
bool CWaypoint::less(CWaypoint const &wp_right)
{
    bool result;
    CWaypoint temp1;

    (calculateDistance(temp1) > temp1.calculateDistance(wp_right)) ?
            result = 1 : result = 0;

    return result;
}

why don't I get an error even when I am not returning a bool type ?

AlexD

An integer-to-boolean conversion takes place. From the C++ standard:

4.12 Boolean conversions [conv.bool]

A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be converted to a prvalue of type bool. A zero value, null pointer value, or null member pointer value is converted to false; any other value is converted to true.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL count(*) returning 0 even though I used IFNULL and COALESCE

From Dev

glGetUniformLocation() returning -1 even though used in vertex shader

From Dev

VLOOKUP Returns 0 even though there is a value in the line below the first result

From Dev

MongoDB for a specific id, query returns array even though size is 0

From Dev

VLOOKUP Returns 0 even though there is a value in the line below the first result

From Dev

Does it matter if a function returns int to a function returning BOOL on Windows?

From Dev

Core Data returns 1, even though there are zero objects fetched

From Dev

compareTo returns -1 even though strings match Java

From Dev

echo $values ['sqlcolumnname']; not returning a displayed value even though vardump $values works

From Dev

Factorial function works in Python, returns 0 for Julia

From Dev

My program reads 0 from the database even though there is a 1

From Dev

Recursive function returning bool

From Dev

Karma returns error and executes 0 out of 0, even though I have one test using Jasime

From Dev

My function in jQuery shows a text in front of the output even though the function self already works

From Dev

Ajax JSON call to back-end function always triggers error response, even though function works correctly

From Dev

javascript function returning undefined even though value display in console.log

From Dev

My server cannot send email even though the mail function is returning true

From Dev

C strstr issue, Returning 0 even when should be 1?

From Dev

R: function returns numeric(0) but code works outside function

From Dev

Runtime.getRuntime().availableProcessors() returning 1 even though many cores available on ECS AWS

From Dev

BufferedReader returns null, even though the stream it's reading from is at pos 0

From Dev

JavaScript returns 'memory' as 0, even though I increase or decrease its value

From Dev

BufferedReader returns null, even though the stream it's reading from is at pos 0

From Dev

Unable to imwrite to PNG even though imshow works

From Dev

Returning Empty from user defined function returns actually 0

From Dev

AXIsProcessTrustedWithOptions returns NO even though the app is on the whitelist

From Dev

peekService returns null even though startService does not

From Dev

dlsym returns NULL, even though the symbol exists

From Dev

Firestore returns a document even though none exists

Related Related

  1. 1

    MySQL count(*) returning 0 even though I used IFNULL and COALESCE

  2. 2

    glGetUniformLocation() returning -1 even though used in vertex shader

  3. 3

    VLOOKUP Returns 0 even though there is a value in the line below the first result

  4. 4

    MongoDB for a specific id, query returns array even though size is 0

  5. 5

    VLOOKUP Returns 0 even though there is a value in the line below the first result

  6. 6

    Does it matter if a function returns int to a function returning BOOL on Windows?

  7. 7

    Core Data returns 1, even though there are zero objects fetched

  8. 8

    compareTo returns -1 even though strings match Java

  9. 9

    echo $values ['sqlcolumnname']; not returning a displayed value even though vardump $values works

  10. 10

    Factorial function works in Python, returns 0 for Julia

  11. 11

    My program reads 0 from the database even though there is a 1

  12. 12

    Recursive function returning bool

  13. 13

    Karma returns error and executes 0 out of 0, even though I have one test using Jasime

  14. 14

    My function in jQuery shows a text in front of the output even though the function self already works

  15. 15

    Ajax JSON call to back-end function always triggers error response, even though function works correctly

  16. 16

    javascript function returning undefined even though value display in console.log

  17. 17

    My server cannot send email even though the mail function is returning true

  18. 18

    C strstr issue, Returning 0 even when should be 1?

  19. 19

    R: function returns numeric(0) but code works outside function

  20. 20

    Runtime.getRuntime().availableProcessors() returning 1 even though many cores available on ECS AWS

  21. 21

    BufferedReader returns null, even though the stream it's reading from is at pos 0

  22. 22

    JavaScript returns 'memory' as 0, even though I increase or decrease its value

  23. 23

    BufferedReader returns null, even though the stream it's reading from is at pos 0

  24. 24

    Unable to imwrite to PNG even though imshow works

  25. 25

    Returning Empty from user defined function returns actually 0

  26. 26

    AXIsProcessTrustedWithOptions returns NO even though the app is on the whitelist

  27. 27

    peekService returns null even though startService does not

  28. 28

    dlsym returns NULL, even though the symbol exists

  29. 29

    Firestore returns a document even though none exists

HotTag

Archive