Instantiating objects 1. Select the constructor you want to use for instantiating the object. 2. When using the default constructor use the syntax {}; 3. When using a non-default constructor use the syntax {}; Using objects 1. Identify the name of the object and its data type (Class used to instantiate it). 2. Identify the member function that performs your intended action. 3. Call the member function by using the syntax .(); 4. If the member function returns a value, assign it to a variable with the same data type as the member function's return type.
Instantiating objects 1. Select the constructor you want to use for instantiating the object. 2. When using the default constructor use the syntax {}; 3. When using a non-default constructor use the syntax {}; Using objects 1. Identify the name of the object and its data type (Class used to instantiate it). 2. Identify the member function that performs your intended action. 3. Call the member function by using the syntax .(); 4. If the member function returns a value, assign it to a variable with the same data type as the member function's return type.
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Write code to instantiate a DonationTracker object using its default constructor. Use the object to donate three amounts: $100.00, $224.25, and $5.75. Get the object's donation count and store it in a variable called num_donations. Get the average donations from the object and store it in a variable called avg_donations.
int main() { std::cout << "Number of donations: " << num_donations << "\n"; std::cout << "Average donation: $" << avg_donations << "\n"; return 0; } |
Expert Solution
Step 1
The C++ code is given in the below step with output screenshots ?
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education