


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this past exam are: Constructor, Destructor, Inheritance, Stored Privately, Class Destructor, Member Function, Inherits
Typology: Exams
1 / 4
This page cannot be seen from the preview
Don't miss anything!



(NFQ – Level 8)
Read instructions carefully Section A : Answer any TWO questions Section B: Answer any TWO questions Use separate answer books for Sections A and B All questions carry equal marks
Examiners: Prof. C. Burkley Mr. J. Ryan Mr. D. O’Donovan Mr. F. O’Reilly
(b) Define a class called TCharBase which consists of the following: i. A constructor which dynamically allocates a character. The character’s value should be supplied as a parameter to the constructor and stored privately.
ii. A member function to return the current contents of a TCharBase object’s character. iii. An appropriate class destructor. [9%]
(c) Define another class called TCharDerived which inherits the TCharBase as public and whose member data consists of a character which is dynamically allocated privately. i. TCharDerived should have a parameterised constructor which takes two parameters. Parameter one should initialise the TCharBase constructor and parameter two should be assigned to the dynamically allocated character in TCharDerived. [5%]
ii. Write a member function for TCharDerived to display both characters. Write additional member function(s) for the TCharBase class, as required. [3%]
(b) What is the purpose of the this pointer? Illustrate its use via an example. [4%]
(c) Define a class called coord, which is capable of representing an x-y coordinate. An example of using such a class is shown in Figure 1. The class should contain the following member functions: i. A parameterised constructor (taking x and y as arguments) with default arguments. [4%] ii. An extractor function to read the x, y coordinates from the keyboard. [5%] iii. An inserter function to display x and y on-screen. [5%] iv. A unary operator, pre-increment ‘++’ i.e. add 1 to x and 1 to y. [4%]
int main(){ coordcin >> a, b(10, 23); a; b++;return 0; } Figure 1
(b) #include <iostream.h> class base { public: int i; }; class derived1 : public base { public: int j; }; class derived2 : public base { public: int k; }; class derived3 : public derived1, public derived2 { public: int product() { return i *j * k; } }; main() { derived3 ob; ob.i = 10; ob.j = 3; ob.k = 5; cout << "Product is " << ob.product() << endl;
(b) Explain how in an x86 Processor, Software Interrupts can be used to execute useful library functions. Your answer should describe the Vector Table, format of addresses and registers values read or changed. [8 %]
(c) The following Assembly code fragment of code uses Interrupt 10 with a value of 14h in ah to print out the single character in al.
mov al, ‘F’ push ax mov ah, 14 int 10h pop ax
Write the x86 assembly code placing it in either a macro or procedure, which can be used to print out a line of astrixes (*) 40 chars wide. Show how it would be used. [9 %]
(b) Describe the steps needed to write the following GUI based program in Visual C++. This checks if a string is a palindrome (same when read from both sides) by reversing the string, which was entered in the normal box and outputting the reversed string.
(c) Describe the Graphics Subsystem available in Windows Programming. In particular you answer should explain Device Context, Device Drivers, Virtual Screen, Stock Objects, Viewport. [8 %]