Hello I need help with these questions that follow this program: THanks in advan
ID: 3868243 • Letter: H
Question
Hello I need help with these questions that follow this program:
THanks in advance
include include using namespace std; const int SIZE = 10; class Bank Acct public: Bank Acct(; //default constructor Bank Acct (double new balance, string Cname) //explicit value //constructor void Print (ostream & out); //accessor function private: double balance; string name; Bank Acct::Bank Acct () balance0 name -"NoName" Bank_Acct: :Bank_Acct (double amount, string Cname) balance = amount ; name cname ; void Bank Acct: : Print (ostream & output) outputendlExplanation / Answer
Chanining
A1: Basically chaining is a possible way to resolve collisions in hash tables. Here chaining is shown for Cascading Multiple Variables through Cout. Basically, 'myAccnt' creates an account object that calls the default constructor. Then the compiler finds an definition of the << operator that can be used with this object, and then 'DrB' creates an account object that calls the parameterised constructor. The <endl> present helps to go to the next line.
Clarity of operator "<<"
A2: The C++ language does not include an I/O system, but one of its core concepts is that it is extendible. Although its operator set cannot be increased, the meanings of operators depend on the context in which they are used. When applied to new objects the meaning can be redefined. So, the left shift operator "<<" has, in the standard I/O library, been overloaded to be the put function when its left hand argument is an input stream.
Return type of "<<"
A3: This operator (<<) applied to an output stream is known as insertion operator.This value can be used again as the left hand size of a "<<". As the operands of cout "<<" cout are user-defined types, the expression is effectively a function call. The compiler must find the best operator "<<" that matches the operands, which in this case are both of type std::ostream.
Purpose of Print
A4: The print function will help to display the information that are taken aas output.It will display the Object name and the amout or balance of the object.
Header prefix
A5: "Bank_Acct" is not prefiexd with header of operator "<<" because the cout function is not the function of "Bank_Acct". It is function of the std::ostream.
A6:
Difference
A friend function is used for accessing the non public member of a class. A class can allow non-member function and other classes to access its own private data by making them friend. A Friend class has full access of private data members of another class without being member of that class but a non-member function is not.
Similarities
A 'Friend' function and a 'Non-Member' function both are not part of the same class.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.