Home > Back-end >  C bool return values only 0 or 1
C bool return values only 0 or 1

Time:02-10

Why when judging both equal bool return value is 2? Boolean value when not 0 or 1? There is no wrong in global function but is in a member function but not why??

 
The class cube {
Private:
Int L;
Int W;
Int H;
Public:
Void setL (int l)
{
L=L;
}
Void setH (int h)
{
H=H;
}
Void setW (int w)
{
W=W;
}
Int getL ()
{
return L;
}
Int getH ()
{
Return H;
}
Int getW ()
{
Return W;
}
Int scare ()
{
Return 2 * (L * W * H + L + H * W);
}
Int tiji ()
{
Return the L * W * H;
}
Bool compare1.c (cube& C)
{
Be sad etH chtistina georgina rossetti.british poetess if (H==() & amp; & Be sad etL chtistina georgina rossetti.british poetess L==() & amp; & Be sad etW chtistina georgina rossetti.british poetess W==())
return true;
Else false.
}
};
Int main ()
{
Cube c1;
C1. SetL (2);
C1. SetH (2);
C1. SetW (2);
Cout & lt; <"Area is:" & lt; Cout & lt; <"Volume is:" & lt; Cube c2.
C2. SetL (2);
C2. SetH (2);
C2. SetW (3);
If (c2.com pare1 (c1))
Cout & lt; <"Equal" & lt; The else cout & lt; <"Not equal" & lt; }

CodePudding user response:

Where to return to 2?
  • Related