Name three benefits of OOP Describe how an ADT is implemente

Name three benefits of OOP.

Describe how an ADT is implemented in C++.

In a stepwise manner, describe how a member function of a class is called.

The “this” pointer is variable maintained by the runtime system of C++ but it is accessible to the programmer. Is it a global or local variable? What is its scope?

What is the function of a constructor? How many constructor can a function have?

When there is no constructor defined in a class, the compiler provides a default constructor. However, if the programmer defines a second constructor, the compiler will not provide the default constructor. What is wrong with the following code and what is the remedy for problem?

class time

{

public:

      time(int, int, int);

      // ... additional member functions

private:

      int hours, minutes, seconds;

};

// assume all member functions have been implemented

int main()

{

      time t1, t2(11, 30, 0);

      // ... additional code

      return 0;

}

Solution

Benefits of oop:

The principle of data hiding helps the programmers to built secure program.

· It is possible to have multiple objects to coexist without any interference.

· It is possible to map objects in the problem domain to those objects in the program.

How ADT is implemented in c++

An ADT is implemented by supplying
a) a data structure for the type name.
b)coded algorithms for the operations.

How member function is called in c++

A member function of a class is a function that has its definition or its prototype within the class definition like any other variable. It operates on any object of the class of which it is a member, and has access to all the members of a class for that object.

This pointer is global or local:

Scope of this variable is within same program.

What is the function of constructor:

A constructor is a kind of member function that initializes an instance of its class. A constructor has the same name as the class and no return value.

How many constructors can function have

Constructor is itself a special member function.


Following code:

class time

{

public:

time(int, int, int);

// ... additional member functions

private:

int hours, minutes, seconds;

};

// assume all member functions have been implemented

int main()

{

time t1, t2(11, 30, 0);

// ... additional code

return 0;

}

The above code calls the paramerised constructor which is declared .

Name three benefits of OOP. Describe how an ADT is implemented in C++. In a stepwise manner, describe how a member function of a class is called. The “this” poi
Name three benefits of OOP. Describe how an ADT is implemented in C++. In a stepwise manner, describe how a member function of a class is called. The “this” poi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site