Explenation

I have this constructor that converts a value into float.
Can anyone break this down step by step
I do not understand the steps in this code.

I need this for my knowlege for C++

P.S. This is just a part code, again I just need the step process

Thanks for the time and help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main ()
{
   Cash t2(5.43f);// this is an object of class Cash.
                  // this activates the class Cash (float)
                  
}

Cash::Cash (float c)// I do not undestand the step by step procces
{
    int cents = static_cast<int>(c * 100 + 0.5);
    
    dollar = cents / 100;
    cents = cents % 100;
    quarter = cents / 25;
    cents = cents % 25;
    dime = cents / 10;
    cents = cents % 10;
    nickel = cents / 5;
    cents = cents % 5;
    penny = cents;	
}
Last edited on
Topic archived. No new replies allowed.