اسئلة عن موضوع Classes and Objects في لغة c++
شرح لي موضوع Classes and Objects في لغة c++
Lab 3: Introduction to Classes and Objects
Lab Objectives:
In this lab students will learn:
The laboratory exercises basic C++ programming skills.
ü The laboratory explores the fundamental concepts of a class such as public, private members, and constructors.
Background:
Students have knowledge about the basic concept of class and object [data members, member function, and constructors].
Lab Problems:
Lab Problem-1:
Write a class named Employee that has the following data members:
o Name: that holds the employee's name.
o Id: is an int variable that holds the employee's id number.
o Salary: is an float variable that holds the employee’s salary.
o Department: that holds the name of the department where the employee works.
The class should have the following constructors and member functions:
o A Default constructor that assigns empty strings (" ") to the name, and department data members, salary to 250 and 0 to the id data members.
o A constructor that accepts the following values as arguments and assigns them to the appropriate data members: employee's name, ID, salary, and department.
o Appropriate mutator (set functions) functions that store values in these data members and accessor (get functions) functions that return the values in these data members.
o A function called AnnualSalary that compute the annual Salary.
تعليقات
إرسال تعليق