Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Thank you Winte a calls and passes der following variable in From the following

ID: 3842058 • Letter: T

Question

Thank you Winte a calls and passes der following variable in From the following for fia our the array mylist]with appropriate numbers 15 What is a constructor, whar is destructor, why would you use both? 16 Can constructor be overloading? Why? 17 Give definitions to public and private access specifiers. 18 Read the following program and create obiect CitiAccount with AccountNumber 23-789" and FullName "John smith" inside of function below class BankAccount private: string AccountNumberi string FullName; BankAccount string nAccountNumber, string name) ill constructor AccountNumber a nAccountNumber: FullName name; sate object CitiAccount with AccountNumber 123-789" and RullName a "John Smith" LET T p C K A R D A HEW

Explanation / Answer

(13)
  
   //Declaring and creating an array of 5 integers
   int arr[5];
  
   //Initializing first element to 4
   arr[0] = 4;

   //Initializing second element to 2
   arr[1] = 2;  
  

   //Initializing last element to 10
   arr[4] = 10;
  

_________________________________________________________________________________________________

(14)

   i = 0; myList[0] = 0 * 2 -1 = -1  
   i = 1; myList[1] = 1 * 2 -1 = 1  
   i = 2; myList[2] = 2 * 2 -1 = 3  
   i = 3; myList[3] = 3 * 2 -1 = 5  
   i = 4; myList[4] = 4 * 2 -1 = 7

   Therefore, myList will contain following data: -1 1 3 5 7

_________________________________________________________________________________________________

(15)
  
   Constructor:
  
  
   It is a special function that gets called automatically when the object is created. It is used for allocating memory and other tasks that needs to be done before using remaining class members.
  
  
   Destructor:
  

   It is a special function that gets called automatically when the object is deleted or goes out of scope. It is used for de-allocating memory and other clean-up tasks
  
_________________________________________________________________________________________________

(16)
  
   Yes Constructor can be Overloaded.
  
   Overloading can be done by passing different type and different number of parameters to constructor.
  
   For example: For a class by name Point
  

   // Default Constructor
   Point() { }
  

   // 1-arg constructor
   Point(int a) { }
  

   // 2-arg constructor
   Point(int a, int b) { }
  

_________________________________________________________________________________________________

(17)
  
   Access Specifiers:

   public:
  
       Members that are declared with public access specifier are accessible with in the class and also outside the class with the help of class object.
          
   private:
  
       Members that are declared with private access specifier are accessible only with in the class but not outside the class.
_________________________________________________________________________________________________

(18)
  
   Creating object with in the main function:
  
   main()
   {
      //Creating BankAccount class object
       BankAccount CitiAccount("123-789", "John Smith");
  
}
           

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote