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

1. Constructor is executed when _____. (5 points) an object is created an object

ID: 3719641 • Letter: 1

Question

1. Constructor is executed when _____. (5 points)

an object is created

an object is used

a class is declared

an object goes out of scope

2. Write the declaration for a class called dog that contains two private data members: a string called breed and an int called age. Then include a default public constructor which will initialize the value breed to bulldog and age to 2. (15 points)

3. Explain with the help of a pseudo-code the purpose of public: and private: access specifiers in a class definition. (10 points)

4. Explain the concept of operator overloading with the help of a C++ pseudo-code. (20 points)

5. State the properties of a Constructor that distinguishes it from other functions. (10 points)

6. State and very briefly explain the three distinct properties of Object Oriented Programming paradigm. (10 points)

7. Explain the concepts of a friend function with the help of a C++ pseudo-code. (10 points)

8. The following generalization: “The number of input arguments required for an overloaded operator function definition is one less than the number of the operands required for its operation”, is true only when ___________ ? (5 points)

9. Friend functions are member functions of the class it is friends with. (True or False?) (5 points)

10. State the properties of accessor and mutator (i.e. getters and setters) functions which can be used to generalize their declarations. (10 points)


Explanation / Answer

Hi Friend,

I have answered first 3 questions in great details.

Please repost others in separate post.

16. Ans: create a table column for each entity attribute
17. Ans. Place the primary key of the entity on the one side into the entity on the
   many side s a foreign key.THe foreign key must not be unique


1. Ans: an object is created

2.
   class dog {

       private:
       string breed;
       int age;
       public:
           dog() {
               breed= "bulldog";
               age = 2;
           }
   }

3.
   Public: All the class members declared under public will be available to everyone. The data members and member functions declared public can be accessed by other classes too. The public members of a class can be accessed from anywhere in the program using the direct member access operator (.) with the object of that class.

   Private: The class members declared as private can be accessed only by the functions inside the class. They are not allowed to be accessed directly by any object or function outside the class. Only the member functions or the friend functions are allowed to access the private data members of a class.

   // C++ program to demonstrate private
// access modifier

#include<iostream>
using namespace std;

class Circle
{
    // private data member
    private:
        double radius;
    
    // public member function  
    public:  
        double compute_area(double r)
        {   // member function can access private
            // data member radius
            radius = r;
           
            double area = 3.14*radius*radius;
           
            cout << "Radius is:" << radius << endl;
            cout << "Area is: " << area;
        }
   
};

// main function
int main()
{
    // creating object of the class
    Circle obj;
   
    // trying to access private data member
    // directly outside the class
    obj.compute_area(1.5);
   
   
    return 0;
}