0% found this document useful (0 votes)
25 views

Lab Assignment-2 (Week-2) : 1. Name 2. Roll No 3. Degree 4. Hostel 5. Currentcgpa

This document contains instructions for 4 programming assignments: 1. Create a Student class with properties (name, roll number, degree, hostel, CGPA) and member functions to add, update, and display student details. 2. Create a Complex class to represent complex numbers, with real and imaginary properties and member functions to set values, display numbers, and add two complex numbers. 3. Create code snippets using the scope resolution operator (::) to access member functions outside a class, global variables when a local has the same name, static class variables, and include libraries. 4. Create a code snippet showing private member functions called within a public member function and accessing private functions from a

Uploaded by

Deepak Aggarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Lab Assignment-2 (Week-2) : 1. Name 2. Roll No 3. Degree 4. Hostel 5. Currentcgpa

This document contains instructions for 4 programming assignments: 1. Create a Student class with properties (name, roll number, degree, hostel, CGPA) and member functions to add, update, and display student details. 2. Create a Complex class to represent complex numbers, with real and imaginary properties and member functions to set values, display numbers, and add two complex numbers. 3. Create code snippets using the scope resolution operator (::) to access member functions outside a class, global variables when a local has the same name, static class variables, and include libraries. 4. Create a code snippet showing private member functions called within a public member function and accessing private functions from a

Uploaded by

Deepak Aggarwal
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Lab Assignment-2 (Week-2)

Q1. Create a class containing the details of Students as details below and a main
function to test the class:
Data Members(properties):
1. Name
2. Roll No
3. Degree
4. Hostel
5. CurrentCGPA

Member Function(behavior):
1. addDetails();
2. updateDetails();
3. updateCGPA();
4. updateResidenceInfo();
5. displaydetails();

Q2. Define a class named Complex with properties (real and imaginary) and methods
as per following details.
void set (float, float) to initialize object values.
void display () to display complex number.
Complex sum (Complex) to add two complex numbers (objects of Complex class) and
return complex number (object of Complex class) as result.

Use pointers to initialize object.

properties (real and imaginary) of the code should have private access modifier and
member functions should have public access modifier in C++ class

Q3. Create code snippets that illustrates the use of scope resolution operator (: :) for the
following uses:

1. Member functions defined outside class


2. To access a global variable when there is a local variable with same name
3. To access a class’s static variables
4. Including In-built libraries

Q4. Create a code snippet that illustrates the following:

1. calling of private member functions inside public member function


2. Access private member functions inside public member function 

You might also like