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

Compiler Design - Limit the Method Instructions, Raj is a newbie to the pro...

Raj is a newbie to the programming and while learning the programming language he came to know the following rules: · Each program must start with ''{'' and end with ''}''. Ã

Create program to newtons method for cube roots, Newton's method for cube r...

Newton's method for cube roots is based on the fact that if y is an approximation to the cube root of x, then a better approximation is given by the value: (x/y 2 +2y)/3 (a)

Describe faster ++i or i++, A: The answer to this lies actually, how they u...

A: The answer to this lies actually, how they used. Along ++i(PreIncrement) the variable is incremented and new value is returned. Thus it needs one instruction to increment the va

Library functions, is getchar() is a C++ library function?

is getchar() is a C++ library function?

If i wish a local to "die" before the close} of the scope, What if I wish a...

What if I wish a local to "die" before the close} of the scope wherein it was created? Can I call a destructor on a local if I want to?

Constructor , What is constructor or ctor? need help

What is constructor or ctor? need help

Explain the parts of operators, Explain the parts of operators Assignm...

Explain the parts of operators Assignment Operators The equal (=) sign is used for assigning a value to another. The left hand side has to be a variable (lvalue, which exc

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