Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

compiler error when creating two functioning classes, how to fix? 1 main.cpp #include 2 #include 3 #include - sinclude 5 #include $ #include 7 #include

compiler error when creating two functioning classes, how to fix?
image text in transcribed
image text in transcribed
1 main.cpp #include 2 #include 3 #include - sinclude 5 #include $ #include 7 #include #include | e using namespace std; 1 class Can 2 { 3 public: 4 string content; 15 double weight; 16 Can(); 17 Can(string s, double d); I 18 Can operator+(const Can &); 19 Can operator-(const Can &); 20 friend can operator+(const Can &c2); 21 }; 22 23 Can Can::operator+(const Can &c2) // c3 = c + c2; 24 25 17 if the content is not the same, content = mixed 26 // else, content - same 27 string newc; 28 if (content != c2.content) 29 { 30 new - "Mixed"; 31 } 32 double nendel - weight + c2.weight; 33 return Can(nesc,nes); 34 } 35 36 ostream& operator 2 #include 3 #include - sinclude 5 #include $ #include 7 #include #include | e using namespace std; 1 class Can 2 { 3 public: 4 string content; 15 double weight; 16 Can(); 17 Can(string s, double d); I 18 Can operator+(const Can &); 19 Can operator-(const Can &); 20 friend can operator+(const Can &c2); 21 }; 22 23 Can Can::operator+(const Can &c2) // c3 = c + c2; 24 25 17 if the content is not the same, content = mixed 26 // else, content - same 27 string newc; 28 if (content != c2.content) 29 { 30 new - "Mixed"; 31 } 32 double nendel - weight + c2.weight; 33 return Can(nesc,nes); 34 } 35 36 ostream& operator

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+ What is the nature of the contracts or agreements with unions?

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago