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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!