Question
c++: Assuming the following class definition: class Order { private: int order_month; public: static const int DEFAULT_MONTH; public: Order ( ) ; int get_month (
c++:
Assuming the following class definition:
class Order { private: int order_month; public: static const int DEFAULT_MONTH; public: Order ( ) ; int get_month ( ) const; };
const int Order::DEFAULT_MONTH = 1; Order::Order ( ) : order_month ( Order::DEFAULT_MONTH ) { } int Order::get_month ( ) const { return order_month; }
1. Declare a const pointer to an Order object namely order_list and initialize it with a dynamically allocated array of 2048 Order objects.
2. What are the array elements' data type and their "values" after the code in question 1 is executed? Your answer must be as specific as possible.
3. Assuming the array has been populated with meaningful data now. Use a regular for loop (no C++ enhanced for loop is allowed) to go thru the entire the array and count the number of orders in May ( 5 is May's integer representation). You must use a separate pointer variable and increment operator to iterate through array's elements. Array notation or (pointer + i) syntax is not allowed.
4. Finally de-allocate the array memory.
Do not write the entire program. You only need to write a piece of code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started