Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ 1. A virtual function provides you with the ability to have several different functions with the same name in a parent and children classes

c++

1. A virtual function provides you with the ability to have several different functions with the same name in a parent and children classes and have C++ figure out which one to call at run-time. True False 2. Suppose cursor points to a node in a linked list (using the node definition with member functions called get_data and get_link). What Boolean expression will be true when cursor points to the tail node (last node) of the list? cursor == NULL cursor->get_link( ) == NULL None of the above cursor->get_data( ) == NULL 3. Consider the following class: class hourlyEmp: public employee { public: hourlyEmp(); hourlyEmp(const string& newName, const string& newSsn, double newPayRate, double newHours); double getHours() const; void setHours(double newHours); void giveRaise(double amount); void printCheck() const; private: double hours; double payRate; }; How could you create an object of this class (Select all that apply)? employee arnold("Arnold Jones","23456664",13,20); hourlyEmp arnold(); employee::hourlyEmp arnold("Arnold Jones"); hourlyEmp arnold("Arnold Jones","23456664",13,20); 4. Which of the following is a pure abstract function? virtual double area() {area= 0}; virtual double area() = 0; pure virtual double area() = {}; abstract double area(); 5. A programming language is required to provide which things in order for it to be considered an object oriented programming language? polymorphism encapsulation function closure support inheritance 6. Consider the following: class base { public: void vfunc() { cout << "This is base's vfunc()." << endl; } }; class derived1 : public base { public: void vfunc() { cout << "This is derived1's vfunc()." << endl; } }; int main() { base *p, b; derived1 d1; p = &b; p -> vfunc(); // remember, this is equivalent to (*p).vfunc(); p = &d1; p -> vfunc(); } What is the output of this program? This is base's vfunc(). This is base's vfunc(). This is base's vfunc(). This is derived1's vfunc(). This is derived1's vfunc(). This is derived1's vfunc(). Error. Ambiguous reference. 7. Consider the following: class base { public: virtual void vfunc() { cout << "This is base's vfunc()." << endl; } }; class derived1 : public base { public: void vfunc() { cout << "This is derived1's vfunc()." << endl; } }; int main() { base *p, b; derived1 d1; p = &b; p -> vfunc(); // remember, this is equivalent to (*p).vfunc(); p = &d1; p -> vfunc(); } What is the output of this program? This is base's vfunc(). This is derived1's vfunc(). This is base's vfunc(). This is base's vfunc(). This is derived1's vfunc(). This is derived1's vfunc(). 8. You wish to convert a container class to a template container class. Which of the following should you consider? Make the class visible to the client. One way to do this is to include the main function in the header file. Make sure operations on container data are not type specific. For example, don't use string functions on container data. Make implementation visible. One way to do this is to include both interface and implementation in the header file. Make sure all return statements that return container dataonly return container data. If a return statement returns container data under certain conditions, but another return statement returns something that is not container data under other conditions, there could be a data type conflict when a different data type is used for this template. 9. Which of the following is a container class in the Standard Template Library? (Select all that apply) string vector sort list 10. Consider the following code. string str1(3, 'a'); cout << str1 << endl; string str2(str1); cout << str2 << endl; string str3("hello", 2); cout << str3 << endl; string str5 = "How are you?"; string str6(str5, 4, 3); cout << str6 << endl; Assuming that this code has the using namespace std directive and the appropriate #include statements, what would you expect the output to be? aaa aa he are he aaa aaa aaa aaa aa he are aaa aaa he are

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions