SlideShare a Scribd company logo
Consider the following C++ program and rewrite the output function as: 1. Non-member function 2.
Friend function Then call both from main and print out the result. #include > using namespace std;
class Money i public: Money(int dollars, int cents); Money(int dollars); Money0: double get value(;
void input (0; void output(O; int get_all_cents O { return all_cents; } private: int all_cents; i; int
main() f Money income; income.input 0 ; cout "Income = "; income.output 0 ; cout << endl;
system("pause"); return 0 ; 3 Money:: Money(int dollars, int cents) i if (dollars*cents <0 ) //If one is
negative and one is positive f cout "Illegal values for dollars and cents. lnn; exit(1); 3 all_cents =
dollars 100+ cents; 3 Money::Money(int dollars) : all_cents(dollars * 100) i //Body intentionally
blank. Money::Money 0 ; all_cents( 0 ) f //Body intentionally blank. 3 double Money::get
value()Money::Money(int dollars, int cents) i if (dollars*cents <0 ) //f one is negative and one is
positive

More Related Content

PPTX
Pointer to Member Function.pptx pointer in c++
PDF
Consider this C++ BankAccount class with the following public member.pdf
PDF
Cbse question-paper-computer-science-2009
PPTX
New presentation oop
PDF
C++ manual Report Full
DOC
Pads lab manual final
PPTX
CPP Homework Help
PPT
Savitch ch 11
Pointer to Member Function.pptx pointer in c++
Consider this C++ BankAccount class with the following public member.pdf
Cbse question-paper-computer-science-2009
New presentation oop
C++ manual Report Full
Pads lab manual final
CPP Homework Help
Savitch ch 11

Similar to Consider the following C++ program and rewrite the output fu.pdf (20)

DOCX
PPT
Savitch Ch 11
PPTX
Pointer example
PDF
Concept_of_NAN_IND_INF_DEN_Using_C++
PPTX
2.6 Friend Function which helps to learn how the friend function works
PPT
DS Unit 6.ppt
PDF
C++ TUTORIAL 1
PDF
Hey, looking to do the following with this programFill in the multip.pdf
DOCX
Bc0037
PDF
Function overloading ppt
PDF
CBSE Question Paper Computer Science with C++ 2011
PPTX
C++_Functions_Presentation of CS eve.pptx
DOCX
#include iostream #include cmath #include iomanipusing n.docx
PDF
chapter-8-function-overloading.pdf
PPT
Lecture2.ppt
PPTX
Silde of the cse fundamentals a deep analysis
PDF
I am having trouble writing the individual files for part 1, which i.pdf
PPT
C++ Functions.ppt
PPT
power point presentation on object oriented programming functions concepts
PDF
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
Savitch Ch 11
Pointer example
Concept_of_NAN_IND_INF_DEN_Using_C++
2.6 Friend Function which helps to learn how the friend function works
DS Unit 6.ppt
C++ TUTORIAL 1
Hey, looking to do the following with this programFill in the multip.pdf
Bc0037
Function overloading ppt
CBSE Question Paper Computer Science with C++ 2011
C++_Functions_Presentation of CS eve.pptx
#include iostream #include cmath #include iomanipusing n.docx
chapter-8-function-overloading.pdf
Lecture2.ppt
Silde of the cse fundamentals a deep analysis
I am having trouble writing the individual files for part 1, which i.pdf
C++ Functions.ppt
power point presentation on object oriented programming functions concepts
2 BytesC++ course_2014_c3_ function basics&parameters and overloading
Ad

More from naslin841216 (20)

PDF
Ynetim Liderlik Vaka almas Maria ailelere destek salay.pdf
PDF
Which of the following is not component of Emotional Intelli.pdf
PDF
Study B Roots Roots and stems often appear similar except .pdf
PDF
Resumen del caso 253 Contratos de compraventa internaciona.pdf
PDF
Question Content Area Use the information provided for Prive.pdf
PDF
PREGUNTA 16 Los siguientes son genotipos de merocigotos de.pdf
PDF
Please answer all or do not answer at all 1 Nearly all ign.pdf
PDF
please summarize i will hit like The year 2021 in Sweden con.pdf
PDF
On average indoor cats live to 12 years old with a standard.pdf
PDF
include ltfunctionalgt include ltiteratorgt inclu.pdf
PDF
Grace makes sure that she walks by her bosss office several.pdf
PDF
Conversion of G3P to RuBP energy and it is coupled to releas.pdf
PDF
need on c++ Task 1 Design a class for Singly linked List wi.pdf
PDF
In the test of hypotheses about three or more population mea.pdf
PDF
During the current year Brewer Company acquired all of the .pdf
PDF
ii If the second segment is lost what is the acknowledgeme.pdf
PDF
Given the matrices B132122Fpath dM403 1759 V84 H666 .pdf
PDF
Destruction results in loss of communication between the R a.pdf
PDF
As of 2010 Xerox Corporation NYSE XRX is a 22 billion .pdf
PDF
ACCT 215 CT Accounting Cycle Problem The John Marshall Com.pdf
Ynetim Liderlik Vaka almas Maria ailelere destek salay.pdf
Which of the following is not component of Emotional Intelli.pdf
Study B Roots Roots and stems often appear similar except .pdf
Resumen del caso 253 Contratos de compraventa internaciona.pdf
Question Content Area Use the information provided for Prive.pdf
PREGUNTA 16 Los siguientes son genotipos de merocigotos de.pdf
Please answer all or do not answer at all 1 Nearly all ign.pdf
please summarize i will hit like The year 2021 in Sweden con.pdf
On average indoor cats live to 12 years old with a standard.pdf
include ltfunctionalgt include ltiteratorgt inclu.pdf
Grace makes sure that she walks by her bosss office several.pdf
Conversion of G3P to RuBP energy and it is coupled to releas.pdf
need on c++ Task 1 Design a class for Singly linked List wi.pdf
In the test of hypotheses about three or more population mea.pdf
During the current year Brewer Company acquired all of the .pdf
ii If the second segment is lost what is the acknowledgeme.pdf
Given the matrices B132122Fpath dM403 1759 V84 H666 .pdf
Destruction results in loss of communication between the R a.pdf
As of 2010 Xerox Corporation NYSE XRX is a 22 billion .pdf
ACCT 215 CT Accounting Cycle Problem The John Marshall Com.pdf
Ad

Recently uploaded (20)

PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Types and Its function , kingdom of life
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PDF
Indian roads congress 037 - 2012 Flexible pavement
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
Trump Administration's workforce development strategy
PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Introduction to Building Materials
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
1_English_Language_Set_2.pdf probationary
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Types and Its function , kingdom of life
Weekly quiz Compilation Jan -July 25.pdf
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Indian roads congress 037 - 2012 Flexible pavement
UNIT III MENTAL HEALTH NURSING ASSESSMENT
Trump Administration's workforce development strategy
What if we spent less time fighting change, and more time building what’s rig...
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
Final Presentation General Medicine 03-08-2024.pptx
Introduction to Building Materials
202450812 BayCHI UCSC-SV 20250812 v17.pptx
1_English_Language_Set_2.pdf probationary
ChatGPT for Dummies - Pam Baker Ccesa007.pdf

Consider the following C++ program and rewrite the output fu.pdf

  • 1. Consider the following C++ program and rewrite the output function as: 1. Non-member function 2. Friend function Then call both from main and print out the result. #include > using namespace std; class Money i public: Money(int dollars, int cents); Money(int dollars); Money0: double get value(; void input (0; void output(O; int get_all_cents O { return all_cents; } private: int all_cents; i; int main() f Money income; income.input 0 ; cout "Income = "; income.output 0 ; cout << endl; system("pause"); return 0 ; 3 Money:: Money(int dollars, int cents) i if (dollars*cents <0 ) //If one is negative and one is positive f cout "Illegal values for dollars and cents. lnn; exit(1); 3 all_cents = dollars 100+ cents; 3 Money::Money(int dollars) : all_cents(dollars * 100) i //Body intentionally blank. Money::Money 0 ; all_cents( 0 ) f //Body intentionally blank. 3 double Money::get value()Money::Money(int dollars, int cents) i if (dollars*cents <0 ) //f one is negative and one is positive