To create a "class object"

Hi experts! Can some one help in explaining the step i can take to create class name "Parking" in a parking ticket calculating system, with member function that will compute the total hours charge after spending 3. the parking rate is $1.50 for the 1st hour and $1.20 for every subsequent hour.
1
2
3
4
5
struct Parking{
   float rate1, rate2;
   
   float getCost(float time);
}
?
thanks. but how can am i going to use the struct in the main function.
This struct you'd use like
1
2
3
Parking p(1.5, 1.2);//I assume you'd write a constructor
int n = 5;
std::cout << "After " << n << " hours, you'll have to pay $" << p.getCost(n) << '\n'; 

Note that I don't know if that is what your assignment wants you to do.
Last edited on
Topic archived. No new replies allowed.