CS410 VU Assignment No 2 Spring 2012 Solution

Question # 01:

We initialize Owner structure, in Assignment No 1, as below;

owner1 = {“Ali Hussain”, “Muhammad Hussain”, “XYZ, Lahore”, “N/A”, 12, 12,2012, “4-Wheel”,

“Honda”, “BR-29536”, “LEV-0012”, 2011, 72000, Vehicle::Van};

Why we are unable to assign a direct value in last attribute of initialization list (enum Vehicle_Class)? (In Bold text). Provide reason in 2 – 3 lines at max.

Solution

That why we need to inherit from the vehicle class while sitting in owner Structure/ class.

 

Question # 02:

Write any alternate way to assign a value ‘Van’ in Vehicle_Class to initialize Owner structure. (Only code is required, no details or text required.)

Solution:

Vehicle v;

Vehicle. V=”car”

 




Question # 03:

Why we use cin.sync () before cin.getline ()? Describe in 2 -3 lines at max.

Solution

we use the cin.sync() before cin.getline(). To print whatever is typed is printed by Synchronizing the Input Stream.

Question # 04:

If we write o2->v.vc = enum_choice; instead of o2->v.vc = (Vehicle::vehicle_class) enum_choice; why this would not work? (For reference, line no 127 of Assignment 1 solution)

Solution:

“enum_choice”  is only the primary expression and it does not know from that from where to inherit/ get data.

Question # 05:

Write an alternate code instead of using string copy function as written on line 83 of Assignment 1 solution. No marks are given to code which is not in working condition.

Solution:

Use the Pointer instead of “.” (dot) operator.

DOWNLOAD SOLUTION HERE
loading...