Programming > SOLUTIONS MANUAL > Solution manual to Introduction to Programming II (All)

Solution manual to Introduction to Programming II

Document Content and Description Below

Discussion: For this question, you had to convert the struct Student into a class. There is essentially only a slight difference between a struct and a class. A class is the same as a struct (i.e. a... struct may also contain both member variables and member functions just like a class, even though the examples in Savitch do not show that) except that, by default, all members are inaccessible to the general user of the class. This means that all members of a struct are by default public, and all members of a class are by default private. Therefore, we have to specify that the member functions are public. (As an exercise, omit the public keyword from the class and recompile it.) While there are situations where a struct is more suitable, as a rule, you should use classes rather than structs. In general, it is preferable to use classes, as classes offer better protection. An object encapsulates or combines data and operations on that data into a single unit. In C++, the mechanism that allows you to combine data and the operations on that data in a single unit is called a class. As name, quiz1, quiz2, midtermExam and finalExam are private member variables (see page 549 of Savitch 6th edition/ page 581 of Savitch 7th edition/ pages 573-582 of Savitch, 8th edition/pages 589-595 of Savitch, 9th edition) of class Student, they cannot be accessed directly in the main() function. As a result, public member functions getQuiz1(), getQuiz2(), getMidtermExam(), getFinalExam() and Term() are used to access these member variables in order to determine their values. These functions are known as accessor functions, while setName(), setQuiz1(), setQuiz2(), setMidtermExam()and setFinalExam()are mutator functions. (Study pages 553-554 of Savitch, 6th edition/ pages 585-586 of Savitch 7th edition/ pages 581-582 of Savitch, 8th edition/ pages 597-598 of Savitch, 9th edition). [Show More]

Last updated: 1 year ago

Preview 1 out of  pages

Add to cart

Instant download

document-preview

Buy this document to get the full access instantly

Instant Download Access after purchase

Add to cart

Instant download

Reviews( 0 )

$7.00

Add to cart

Instant download

Can't find what you want? Try our AI powered Search

OR

REQUEST DOCUMENT
4
0

Document information


Connected school, study & course


About the document


Uploaded On

Sep 27, 2021

Number of pages

Written in

Seller


seller-icon
Ephantus

Member since 2 years

Documents Sold


Additional information

This document has been written for:

Uploaded

Sep 27, 2021

Downloads

 0

Views

 4

Document Keyword Tags

What is Browsegrades

In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.

We are here to help

We're available through e-mail, Twitter, Facebook, and live chat.
 FAQ
 Questions? Leave a message!

Follow us on
 Twitter

Copyright © Browsegrades · High quality services·