How private instance of a class can be assigned values, C/C++ Programming

Assignment Help:

Question 1:

(a) Explain clearly the following concepts using suitable examples of your own:-

(i) concrete class v/s abstract class
(ii) constructor v/s overloaded constructor
(iii) single inheritance v/s multiple inheritance
(iv) polymorphism v/s data encapsulation

(b) (i) Explain how a static method can be used in a program to access data members?

(ii) Explain how private instance variables of a class can be assigned values?

Question 2:

(a) Write down the abstract class 'BloodDonor' to contain the following:-

(i) integer variable: donor_id
String variables: donor_name, address
double-precision variable: bloodAmount
(ii) set methods for data members: donor_id, donor_name, address
(iii) get methods for all data members
(iv) abstract method 'giveBlood' which returns nothing

(b) Write down the subclass 'Student' to contain the following:-

(i) integer variable: student_id
(ii) set method for the data member
(iii) get method for the data member
(iv) override the abstract method 'giveBlood' to assign a value of 1.0 to the attribute 'bloodAmount'

(c) Write down the subclass 'StaffWorker' to contain the following:-
(i) double-precision variable: salary
(ii) set method for the data member

(iii) get method for the data member
(iv) override the abstract method 'giveBlood' to assign a value of 2.0 to the attribute 'bloodAmount'

(d) Write down an application to perform the following tasks:-
(i) create one 'Student' object and one 'StaffWorker' object
(ii) assign values to the data members of each object
(iii) display all the values


Related Discussions:- How private instance of a class can be assigned values

How can define an array, Q: How can Define an Array? An Array is define...

Q: How can Define an Array? An Array is defined in much the alike manner as ordinary variables except that every array name must be accompanied by a size specification (that is

Function with unsigned char parameters, Write a function that has four uns...

Write a function that has four unsigned char parameters, combines the four one-byte integer values into an unsigned integer, and returns the unsigned integer. When the four one

C program to reverse the elements of array, C program to reverse the elemen...

C program to reverse the elements of array: #define rows 3 #define cols 3 void main() {                 int i=0,j=0;                 int arr[rows][cols];

Do friends break encapsulation?, A: No. If they're utilized properly, they ...

A: No. If they're utilized properly, they increase encapsulation. You frequently require splitting a class in half while the two halves will have distinct numbers of instances o

Copy constructor and an overloaded assignment operator, What is the differe...

What is the difference among a copy constructor and an overloaded assignment operator? Ans) A copy constructor constructs a latest object by using the content of the argument

What is default argument, Default argument: When the argument is missin...

Default argument: When the argument is missing then the function will read the default value of the missing argument.  To make use of default argument functionality the argu

C program to demonstrate pointer to variable, C program to demonstrate Poin...

C program to demonstrate Pointer to variable: void p2a(int *); void main() {                 int x=10, *a,**b;                 int arr[5];                 //poin

Define bitwise left shift and right shift operators, Define Bitwise Left Sh...

Define Bitwise Left Shift and Right Shift Operators: >? The bitwise shift operators shift their first operand right (>>) or left ( // Illustration of the bitwise right shi

Padovan string ., #questio#A Padovan string P(n) for a natural number n is ...

#questio#A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes string concate

Wap to print the largest number from any 10 numbers, WAP TO PRINT THE LARGE...

WAP TO PRINT THE LARGEST NUMBER FROM ANY 10 NUMBERS #include stdio.h> #include conio.h>   void main()   {                    int a[10],i,max;

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd