cs304 final term solved papers by moaaz

cs304 final term solved papers by moaaz. Default constructor: Default constructor is such constructor which either has noparameter or if it’s some parameters these have default values. The benefit ofdefault constructor is that it are often wont to create class object without passing anyargument.

Implicit Default constructor:Compiler generates implicit default constructor for any class just in case we’ve notgiven any constructor for the category.


Explicit Default constructor:If user has given constructor for any class with none arguments or with allarguments with default parameters then it’s also default constructor according todefinition but it’s explicit default constructor.Now if a base class has only non-default constructor (implicit or explicit).

See also:

cs402 final term solved papers by moaaz mcqs

CS301 final term solved papers by waqar

cs401 final term solved papers by moaaz

cs201 final term solved papers by moaaz

Then whenwe will create object of any class derived from this base class compiler won’t beable to call base class constructor as base class has no default constructor (constructor which will be called without giving any parameters) so compiler willgenerate error.We can avoid this error by calling base class non-default constructor in derived classconstructor initializer list.

Accessing base class member functions in derived class:Public methods of base class can directly be accessed in its derived class (derivedclass interface consists of its own member functions plus member functions of itsbase class).However there are some class members functions that are written even as helperfunctions for other class member functions and that they needn’t to be called directlyusing class object for instance.


1. Suppose some function in our class wants to urge some input from user in theform of integers just for this we will write another function that checkswhether the entered string by user consists of integers only.


2. Suppose our class has implement encryption of knowledge, and it encodes anddecodes data using some functions these functions also will to helperfunctions and will not be accessible to outside word.


3. Similarly take the instance of our Date class we sSimilarly take the instance of our Date class we studied in lecture no.13 has afunction to see whether an year is intercalary year or not and consistent with resultit allows or disallows the times of February to be 29.


This bool IsLeapYear(int) will employed by other members functions of Date class like void setDay( int )and void addDay( int ), this functions is additionally helper function.These helper functions are made private as there’s no got to access them usingclass object directly.


Making such functions private works fine as long as we don’t derive any child classfrom this class, but once we derive some class for specialization these functions willnot be accessible within the derived class as private members functions are accessibleonly in those class to which they belong but these functions are needed in derivedclasses also.

cs304 final term solved papers by moaaz


Scholarships 2021-2022