Question
EXERCISES FOR C++ 1. What's wrong with this code? How do we fix it? class Item { private: const int size; // must be initialized
EXERCISES FOR C++
1. What's wrong with this code? How do we fix it?
class Item {
private:
const int size; // must be initialized with value 10
public:
Item ( );
} ;
Item::Item ( ) {
size = 10;
}
2. Copy/paste the BankAccount class in sub-module "Classes - the heart of OOP" into your IDE and compile with an empty main function such as
int main ( ) { }
// Have you seen enough of no-opt function with empty brackets like this { } ?
3. Now add code to the main function to
a. Create a default bank account
b. Create a non-default bank account
c. Output to Console the bank routing member. How many ways can you do it? What's the correct way to do it?
d. Invoke accessor/mutator functions on non-default account (output to console if needed)
e. Invoke behavioral functions and verify that it works (try both negative/positive amounts)
Finally recompile the code and run the program to verify your code is working.
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