Access Millions of academic & study documents

All questions are in C++1) Here is a function definitionvoid fu

Content type
User Generated
Showing Page:
1/6
All questions are in C++
1) Here is a function definition:
void func(int& i, int k)
{
i = 1;
k = 2;
}
Suppose that a main program has two integer variables x
and y and both are given the value 0. Then the main
program calls func(x,y); What are the values of x and y
after the function func finishes?
A. Both x and y still 0.
B. x is now 1, but y is still 0.
C. x is still 0, but y is now 2.
D. x is now 1, and y is now 2.
2) Here is a function prototype and some possible function
calls:
int sumOfThreeNumbers(int, int = 20, int = 30);
// Possible function calls:
cout << sumOfThreeNumbers ();
cout << sumOfThreeNumbers (23, 15);
cout << sumOfThreeNumbers (23, , -30);
cout << sumOfThreeNumbers (23, 15, -30);
How many of the above function calls are legal?
A. None of them is legal.
B. 1 of them is legal.
C. 2 of them are legal.
D. 3 of them are legal.
E. All of them are legal.
3) Is it possible for a member function of a class to
activate another member function of the same class?
A. No.
B. Yes, but only public member functions.
C. Yes, but only private member functions.
D. Yes, both public and private member functions can

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/6
be activated within another member function.
4) Which of the following is a correct declaration of the
extraction operator >> overloading function for a class
MyClass?
A. void operator>>(istream& isObj);
B. istream& operator>>(istream& isObj);
C. friend void operator>>(istream& isObj, MyClass&
obj);
D. friend istream& operator>>(istream& isObj,
MyClass& obj);
5) Here is the start of a class declaration:
class ClassA
{
public:
void func1(const ClassA& a);
void func2(ClassA& a) const;
void func3(ClassA a) const;
...
Which of the three member functions can alter the private
member variables of the ClassA object that activates the
function?
A. None of the three functions.
B. Only func1.
C. Only func2.
D. Only func3.
E. Only two of the three functions.
Solution
1) Here is a function definition:

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/6

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 6 pages?
Access Now
Unformatted Attachment Preview
All questions are in C++ 1) Here is a function definition: void func(int& i, int k) { i = 1; k = 2; } Suppose that a main program has two integer variables x and y and both are given the value 0. Then the main program calls func(x,y); What are the values of x and y after the function func finishes? A. Both x and y still 0. B. x is now 1, but y is still 0. C. x is still 0, but y is now 2. D. x is now 1, and y is now 2. 2) Here is a function prototype and some possible function calls: int sumOfThreeNumbers(int, int = 20, int = 30); // Possible function calls: cout (istream& isObj); B. istream& operator>>(istream& isObj); C. friend void operator>>(istream& isObj, MyClas s& obj); D. friend istream& operator>>(istream& isObj, MyClass& obj); 5) ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents