Question
Service Class
Create a class named Service with private data members to store:
Answer :
Word Count : 1217
__________ _____ ______ ___ _____ _________ _____ _____ ___ ___ ______.
_____ ____ ________ _________ _______ _____ ________ ______ _______.
_________ __________ ________ ________ ___ _______ ___ __________ ____ ______ __________.
________ __________ ___ _________ _______.
_____ _______ _____ _____ ____ ____ ___ ________ _________ _____ ____.
________ _______ __________ __________ __________ ___.
____ ___ ________ _________ _________ ___ ___.
__________ ______ ______ ___ ______ _________ _________ _____ _______.
_______ ______ _______ ________ ____ _____ ______ __________ _________.
____ _______ _________ _______ ________ _______ _______.
___ ________ _________ ____ ____ __________ ___ ___ _____ ______ _____.
__________ ______ _________ _____ ___ _______ _______ _____ _________ ___.
___ ______ __________ _____ __________ __________ ___ ___ ______.
__________ __________ ____ __________ ___.
__________ ___ __________ ______ ________ ___.
____ ________ ________ _____ ___ ________ __________ ____ _____.
_______ ____ ______ _________ _____ ____ _______.
____ ________ ________ _______ _________ _____.
_______ __________ ___ ________ _____ __________ ________ _________.
______ _______ ___ __________ ________.
______ ______ _________ _____ __________ _______ _______ _____ ___ ______ _______ ______.
____ ____ _______ _____ ________ ____ ___ ______.
______ _____ __________ __________ _____ ___ _________ __________ _____ ___ _______ _________.
_____ ___ ____ ______ _____ ____ ___ __________ ____ ______.
_____ ___ __________ ______ ___ _______ _______ ______ __________ _______.
________ ________ _______ ____ __________ _________ _________ ____ ____.
____ __________ _______ ______ ___.
____ _______ ________ ______ ______ ______ ___ _________ _____ ___.
__________ __________ ___ ___ __________ ______ _____ _____.
_______ ____ ______ _________ ___ ______ _____ ______ ______.
_______ _________ ________ __________ _______ ______ ___.
________ ________ _________ ____ __________ _________ __________ ___ ____.
_______ _____ _________ __________ _____ ____ _____ ________ ____ ________.
__________ __________ ______ ________ ___ __________.
___ _______ _________ _______ _____ ______ _______ __________ __________.
___ ___ ____ _______ ___ ______ ______.
____ ________ _______ _______ ____ ______.
_______ _______ ______ ____ ________ __________ ____ _______ _______.
______ _________ _______ ________ ________ _________ __________ ___.
__________ _______ ____ ______ ___ __________ ________ ______.
________ _________ ___ ___ ______ ______ ____.
___ _________ ____ ________ _______ _____ ___.
___ _______ ________ ________ _______ _________ _________.
__________ ___ ______ ___ ____ ____ ________ ____ __________ __________.
_______ __________ ____ ______ _______ ___ ______.
_____ _____ ________ __________ ________ _______ ______ ________ _____ ____ _________.
__________ _________ _______ ____ _________.
____ ______ ____ _____ ______.
______ ______ _____ _______ _____ ___ _______ _________ _____ __________ _____.
________ _____ ________ _________ __________ ___ _______ _______.
______ _____ ______ _____ _________ ___ _____ ____ ______ _________ ____ _______.
__________ ____ ___ ________ ___ _________ _____ ____ ________ ___.
______ ______ __________ _____ ________.
_________ ___ ________ ___ __________ ___ ____ ___.
__________ ________ __________ ______ ______ ___ ______ ________ ___ ____ ____ _______.
__________ ________ ______ ______ ____ ____ ___ ________ ___ ______ _________ ___.
_______ ______ _________ ______ _________ ____.
_____ _________ ________ _____ _____ _________ ___ ___ ___ _________ ___ ___.
______ _______ __________ _______ _______.
_________ _______ ______ ________ _____ ____ ______ ________ ________ _____ ____.
_______ ___ ______ ___ _______ _________ ____.
_____ _________ ___ __________ ______ _______ ______ _______ ___ _________ _________ _______.
________ ________ ______ _____ ______ _______ ________ ________.
_________ _________ ___ ____ ____ __________ ________ ___ _______.
___ ________ _____ __________ ___.
__________ _______ ______ __________ _______ ___ _____ ________ __________ ____ _________.
__________ ____ __________ ____ ____ _____ _____ ________ _______ _____.
_______ _______ ________ ______ ________ ____ ____ __________ ____ __________ _____ _____.
__________ ___ _____ ___ __________ ___ __________.
_________ __________ _____ ______ ___ _______ _____ ___ ____ ____ ___.
_____ _____ ________ ___ _________ ______ _________ ________ ______ ________.
_____ __________ _____ ___ ________ _______ _________ ________ _____.
__________ __________ ___ __________ __________ _______.
______ _____ ____ ______ ______ ____.
______ _____ ________ ____ ________ _________ ______ ______ ____ ______ _______ ______.
_____ _______ ______ ______ _______ _________ _____ _______.
_______ _________ _________ _______ _______ ____ _____ ________ ___ _________ _______.
__________ _________ ____ _______ ___ ____ _________ _______ ____.
________ ______ ___ ___ ________ _____.
______ _______ _______ ______ _______.
_____ ____ ________ _________ _____ __________ ___ ___.
_____ __________ _____ _____ ___ __________ ____ ____ __________ _______ __________ ________.
___ ______ ______ ______ ________.
_______ ____ ______ _______ _________ ______ ________ _________.
___ _____ _____ ______ _____ __________ _______ _____ ______ ________ _________ ________.
____ ___ _____ __________ ___ ________ ___ ______ _________ _______.
___ __________ __________ ________ ______ _________ ________.
_______ __________ __________ _______ ____ __________.
________ ____ ___ ____ ______ ___.
_________ __________ _____ ____ _____ _________ ________.
________ _________ ________ ________ ________ _______ _______ __________ _____ _____ _____.
____ ________ ____ ____ _____ ______.
_____ _______ ___.
Skip in 10
Create a class named `Service` with private data members to store the details of a service. In a DBMS and C++ Lab context, the class can be designed to represent one record of a service entity, similar to a row in a database table. The private data members ensure that the service information cannot be accessed or modified directly from outside the class. This principle is known as data hiding and is an important feature of object-oriented programming in C++. A suitable implementation can use data members such as `serviceId`, `serviceName`, `serviceType`, and `serviceCost`. The service ID can uniquely identify each service, the service name can store the name of the service, the service type can describe the category of service, and the service cost can store the amount charged for the service. The exact members can be changed according to the fields specified in the practical question. ```cpp #include #include using namespace std; class Service { private: int serviceId; string serviceName; string serviceType; float serviceCost; public: void setData() { cout << "Enter Service ID: "; cin >> serviceId; cin.ignore(); cout << "Enter Service Name: "; getline(cin, serviceName); cout << "Enter Service Type: "; getline(cin, serviceType); cout << "Enter Service Cost: "; cin >> serviceCost; } void displayData() { cout << "\nService ID: " << serviceId; cout << "\nService Name: " << serviceName; cout << "\nService Type: " << serviceType; cout << "\nService Cost: " << serviceCost << endl; } }; int main() { Service s; s.setData(); s.displayData(); return 0; } ``` The statement `class Service` declares a class named `Service`. A class is a user-defined data type in C++ that combines data members and member functions into a single unit. In this program, the class represents a service record. This approach is useful in database-oriented applications because database records can be represented as objects in C++. The keyword `private` is used before the data members. Therefore, `serviceId`, `serviceName`, `serviceType`, and `serviceCost` cannot be accessed directly through an object from the `main()` function. For example, a statement such as `s.serviceId = 101;` would produce an access error because `serviceId` is private. This protects the data from unauthorized direct modification. The `serviceId` member is declared as an integer because an identification number is generally represented by a numeric value. The `serviceName` and `serviceType` members are declared as `string` because they contain textual information. The `serviceCost` member is declared as `float` because the cost may contain decimal values. The `public` section contains member functions that provide controlled access to the private data. The `setData()` function is
_________ ________ ____ _______ ______ _______ ________ ___ _________ _______ _______ ______.__________ _____ ______ ___ _____ _________ _____ _____ ___ ___ ______.
_____ ____ ________ _________ _______ _____ ________ ______ _______.
_________ __________ ________ ________ ___ _______ ___ __________ ____ ______ __________.
________ __________ ___ _________ _______.
_____ _______ _____ _____ ____ ____ ___ ________ _________ _____ ____.
________ _______ __________ __________ __________ ___.
____ ___ ________ _________ _________ ___ ___.
__________ ______ ______ ___ ______ _________ _________ _____ _______.
_______ ______ _______ ________ ____ _____ ______ __________ _________.
____ _______ _________ _______ ________ _______ _______.
___ ________ _________ ____ ____ __________ ___ ___ _____ ______ _____.
__________ ______ _________ _____ ___ _______ _______ _____ _________ ___.
___ ______ __________ _____ __________ __________ ___ ___ ______.
__________ __________ ____ __________ ___.
__________ ___ __________ ______ ________ ___.
____ ________ ________ _____ ___ ________ __________ ____ _____.
_______ ____ ______ _________ _____ ____ _______.
____ ________ ________ _______ _________ _____.
_______ __________ ___ ________ _____ __________ ________ _________.
______ _______ ___ __________ ________.
______ ______ _________ _____ __________ _______ _______ _____ ___ ______ _______ ______.
____ ____ _______ _____ ________ ____ ___ ______.
______ _____ __________ __________ _____ ___ _________ __________ _____ ___ _______ _________.
_____ ___ ____ ______ _____ ____ ___ __________ ____ ______.
_____ ___ __________ ______ ___ _______ _______ ______ __________ _______.
________ ________ _______ ____ __________ _________ _________ ____ ____.
____ __________ _______ ______ ___.
____ _______ ________ ______ ______ ______ ___ _________ _____ ___.
__________ __________ ___ ___ __________ ______ _____ _____.
_______ ____ ______ _________ ___ ______ _____ ______ ______.
_______ _________ ________ __________ _______ ______ ___.
________ ________ _________ ____ __________ _________ __________ ___ ____.
_______ _____ _________ __________ _____ ____ _____ ________ ____ ________.
__________ __________ ______ ________ ___ __________.
___ _______ _________ _______ _____ ______ _______ __________ __________.
___ ___ ____ _______ ___ ______ ______.
____ ________ _______ _______ ____ ______.
_______ _______ ______ ____ ________ __________ ____ _______ _______.
______ _________ _______ ________ ________ _________ __________ ___.
__________ _______ ____ ______ ___ __________ ________ ______.
________ _________ ___ ___ ______ ______ ____.
___ _________ ____ ________ _______ _____ ___.
___ _______ ________ ________ _______ _________ _________.
__________ ___ ______ ___ ____ ____ ________ ____ __________ __________.
_______ __________ ____ ______ _______ ___ ______.
_____ _____ ________ __________ ________ _______ ______ ________ _____ ____ _________.
__________ _________ _______ ____ _________.
____ ______ ____ _____ ______.
______ ______ _____ _______ _____ ___ _______ _________ _____ __________ _____.
________ _____ ________ _________ __________ ___ _______ _______.
______ _____ ______ _____ _________ ___ _____ ____ ______ _________ ____ _______.
__________ ____ ___ ________ ___ _________ _____ ____ ________ ___.
______ ______ __________ _____ ________.
_________ ___ ________ ___ __________ ___ ____ ___.
__________ ________ __________ ______ ______ ___ ______ ________ ___ ____ ____ _______.
__________ ________ ______ ______ ____ ____ ___ ________ ___ ______ _________ ___.
_______ ______ _________ ______ _________ ____.
_____ _________ ________ _____ _____ _________ ___ ___ ___ _________ ___ ___.
______ _______ __________ _______ _______.
_________ _______ ______ ________ _____ ____ ______ ________ ________ _____ ____.
_______ ___ ______ ___ _______ _________ ____.
_____ _________ ___ __________ ______ _______ ______ _______ ___ _________ _________ _______.
________ ________ ______ _____ ______ _______ ________ ________.
_________ _________ ___ ____ ____ __________ ________ ___ _______.
___ ________ _____ __________ ___.
__________ _______ ______ __________ _______ ___ _____ ________ __________ ____ _________.
__________ ____ __________ ____ ____ _____ _____ ________ _______ _____.
_______ _______ ________ ______ ________ ____ ____ __________ ____ __________ _____ _____.
__________ ___ _____ ___ __________ ___ __________.
_________ __________ _____ ______ ___ _______ _____ ___ ____ ____ ___.
_____ _____ ________ ___ _________ ______ _________ ________ ______ ________.
_____ __________ _____ ___ ________ _______ _________ ________ _____.
__________ __________ ___ __________ __________ _______.
______ _____ ____ ______ ______ ____.
______ _____ ________ ____ ________ _________ ______ ______ ____ ______ _______ ______.
_____ _______ ______ ______ _______ _________ _____ _______.
_______ _________ _________ _______ _______ ____ _____ ________ ___ _________ _______.
__________ _________ ____ _______ ___ ____ _________ _______ ____.
________ ______ ___ ___ ________ _____.
______ _______ _______ ______ _______.
_____ ____ ________ _________ _____ __________ ___ ___.
_____ __________ _____ _____ ___ __________ ____ ____ __________ _______ __________ ________.
___ ______ ______ ______ ________.
_______ ____ ______ _______ _________ ______ ________ _________.
___ _____ _____ ______ _____ __________ _______ _____ ______ ________ _________ ________.
____ ___ _____ __________ ___ ________ ___ ______ _________ _______.
___ __________ __________ ________ ______ _________ ________.
_______ __________ __________ _______ ____ __________.
________ ____ ___ ____ ______ ___.
_________ __________ _____ ____ _____ _________ ________.
________ _________ ________ ________ ________ _______ _______ __________ _____ _____ _____.
____ ________ ____ ____ _____ ______.
_____ _______ ___.
IGNOU ACADEMY
Your IGNOU journey, made easier.
- Solved Assignments
- Study Notes
- Guess Papers
- Question Papers
Continue Reading — It's Free
Sign in with Google to unlock more of this answer.
✓ Free access
✓ Unlock up to 60% of the answer
✓ No payment required
✓ Unlock up to 60% of the answer
✓ No payment required
Quick Google sign-in. No separate registration form.