Home > Back-end >  As a condition of judgment about the object
As a condition of judgment about the object

Time:12-14

C + + often see the object as a condition of judgment, is how to determine, interior is going on

CodePudding user response:

Object instance or object pointer? What kind of judgment conditions? Compare the size? The original poster can give a practical examples?

CodePudding user response:

C + + is a value as a condition of judgment, there is no judgment of the object, the value 0 is false, non-zero is true,

CodePudding user response:

reference 1st floor SuperDay response:
object instance or object pointer? What kind of judgment conditions? Compare the size? The original poster can give a practical examples?

Such as cin objects themselves from smart Pointers

CodePudding user response:

reference 1st floor SuperDay response:
object instance or object pointer? What kind of judgment conditions? Compare the size? The original poster can give a practical examples?

Typo,
Cin object and from smart Pointers, the two objects

CodePudding user response:

Pointer is to directly compare the address, if you want to determine whether the same object, is to directly compare the address the same

CodePudding user response:

reference 5 floor SuperDay reply:
pointer is to directly compare the address, if you want to determine whether the same object, a direct comparison address is equal to the

May be I say not clear,

The first kind of
If (cin) {}
The second
From & lt; Int> a;
If (a) {}
Cin object and object a as condition here, what time is right, what time error, how to judge,

CodePudding user response:

The NULL is whether it is empty

CodePudding user response:

If (obj)...
if(! Obj...

C + + can be overloaded bool operation, so I have to see the class definition, specific
  • Related