# What is "p" in Person p?

#1

I am bit confused about the p in the Person parameter. Why do I have to put this in the function for the body mass index?
amidabrian

#2

Iâm not sure I understand the question. The function bodyMassIndex() takes a parameter â a Person structure â and returns that personâs BMI. So, when you call the function, you supply a Person structure.

The name of the parameter is p in the function. The name of the variable that is holding the person in the main function is person. Those variables are in different frames.

#3

I suppose what I am asking is what is p in the bodyMassIndex function? I followed your previous example but this example has throw me a bit. Sorry to act a bit stupid but I am trying to get my head around this. Why could the bodyMassIndex function be float bodyMassIndex(Person)
{
return weightInKilos/(heightInMeters*heightInMeters)
}

Great a book and looking forward to more discoveries.

#4

I get it now- The parameters takes the argument of 96 and 1.8. Is that right?

#5

I get it now- The parameters takes the argument of 96 and 1.8. Is that right?

#6

I see what you mean. I did a gut check the first time I saw âfloat bodyMassIndex(Person p)â as well. Itâs similar to saying âfloat bodyMassIndex(int p)â only in that p is of type int just as p is of type Person (or is it âstruct Personâ?). If you understand how âfloat bodyMassIndex(int p)â works, then understanding âfloat bodyMassIndex(Person p)â is just a small step away.

Building on concepts is the name of the game in this book and you can always refer back to previous material to understand current material and that, for me, has been key in the learning process.

Good stuff.

#7

The example might be easier to understand if the human being who weighs 96 kg and is 1.8 m tall was called (for example) Aaron instead of person.

#8

Ironically I was thinking exactly the same thing about it being easier to follow with person/human rather than person/person as I was doing the example.

#9

Where I am confused is:

âfloat bodyMassIndex(Person p)
{
return p.weightInKilos / (p.heightInMeters * p.heightInMeters);
}â

If the function parameter is p then why do we need to have âp.weightInKilosâ or âp.heightInMetersâ or âp.heightInMetersâ? p has already been specified in the function argument.