التخطي إلى المحتوى الرئيسي

موضوع Classes and Objects في لغة c++


اسئلة عن موضوع 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.

تعليقات

المشاركات الشائعة من هذه المدونة

شرح + اسئله عن موضوع Arrays في لغة c++

شرح + اسئله عن موضوع  Arrays في لغة c++  1: Arrays   Lab Objectives: ü Learn how to use the array data structure to represent a set of related data items. ü Learn how to declare arrays, initialize arrays and refer to the individual elements of arrays. ü Learn how to pass arrays to functions. ü Learn how to declare and manipulate Two-dimensional arrays. ü  Background:   Definition Array: A collection of individual values, all of the same data type, stored in adjacent memory locations. One Dimensional Array: An array with a single variable index. Using the array name together with an integral valued index in square brackets refers to the individual values. The first array element always has the subscript 0. The second array element has the subscript 1, etc. The base address of an array ...

شرح + اسئله لموضوع Pointers في لغة c++

شرح + اسئله لموضوع Pointers في لغة c++ Lab 2: Using Pointers Lab Objectives: In this lab students will learn: ü Memory concept of variables, pointers and how to use variable identifiers and pointers to refer to the variable. ü Pointer variable declarations and initialization. ü Direct and indirect referencing a variable using the pointer operators. ü Using * and address (&) operators.   Background: When declaring a variable, it is located at a specific location in memory, the memory address. The task of locating variables is automatically performed by the operating system during runtime. In some cases we need to know the address where the variable is being stored during runtime. Variable which stores a reference to another variable is called a pointer. We can directly access the value stored in the variable using a ...

شرح ع كلاس class للغة c++

شرح ع كلاس class للغة c++ اسئله عن موضوع  كلاس class للغة c++ Lab 4: Using different handles to access class members,and Writing and using destructors.   Lab Objectives: ü Understand class scope and accessing class members via the name of an object, a reference to an object or a pointer to an object. ü Writing and using destructors to perform "termination housekeeping" on an object before it is destroyed. ü Declaring local, global, and static local objects. ü Learn when constructors and destructors are called and the order in which they are called. ü Defining utility functions. Student Learning Outcomes: You will: ü Be able to use object name or a reference to an object or a pointer to an object to access different cl...