#include #include using namespace std; string type = "Credit"; class credit card { public: }; credit
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
#include #include using namespace std; string type = "Credit"; class credit card { public: }; credit
b. The lifetime, begin & end, of this element? Why?
type
Which area: [1] [2] [3] [4a] [4b] [5]
Why is that area?
What is its lifetime and why?
cc2
Which area: [1] [2] [3] [4a] [4b] [5]
Why is that area?
What is its lifetime and why?
cc3, the object
Which area: [1] [2] [3] [4a] [4b] [5]
Why is that area?
What is its lifetime and why?
CC4, the object
Which area: [1] [2] [3] [4a] [4b] [5]
Why is that area?
What is its lifetime and why?
c. What is the output of the program?
#include <iostream> #include <string> using namespace std; string type = "Credit"; class credit card { public: }; credit card ()=default; } explicit credit card (const double & balance, string com = "Disney") : com_(move (com)), balance_ (balance) {} void display_info() const { cout << credit card: :type_ << " [" << this->com_ << "]: " << this->balance_ << endl; } private: } } void set_com (const string & com) { this->com_ = com; string credit card: :type_ = type; credit card& update_credit card (const double& balance) { balance }; static string type_; string com_{ "N/A" }; double balance_{0}; credit card ccl static credit card* cc2 = new credit card { 100 }; cc1.set_com ("Tesla"); *cc2cc1; return *cc2; int main() { credit card cc3 = update_credit card (300); cc3.display_info(); credit card cc4 = credit card { cc3 }; cc4.set_com ("Zoom"); cc4.display_info(); credit card* cc5 = new credit card{ update_credit_card (500) }; cc5->display_info(); cc3.set_com ("Google"); cc4.display_info(); return 0;