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

موضوع 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.

تعليقات

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

شرح + اسئله لموضوع 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 ...

شرح + اسئله عن موضوع 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 ...

شرح واسئله عن Friend function & friend class.

موضوع Friend function & friend class Task #6: Friend function & friend class.   Create and destroy objects dynamically. Static data members and member functions.     Objectives:   Using friend functions, and friend classes.   Using this pointer.    Creating and destroying objects dynamically with operators new and delete, respectively.    Creating dynamic array class.   Using static data members and member functions.   Student Learning Outcomes:   You will: Be able to write a friend function and friend class. Be able to allocate and de allocate objects dynamically.   Background:   You have learned the syntax of friend function, friend class, this pointer, and delete and new operators. You have also learned how to write a static data members and member functions.