What is the value of arysize after executing the following code: Answer: int testAry[] = { 1,5,8,9,6,7,3,4,2,0 }; int arysize = sizeof(testAry) / sizeof(testAry[5]); 0101 111101101 01010 To pass an object of type struct or class to a function as an argument, which of the following is true? (Select all that apply) a. You can pass it by reference b. You can pass it by value c. You can pass it by value but not by reference d. You can pass it by reference but not by value e. None of the answers Based on the code of contiguous queue, create a non-member function (friend) that uses operator overloading to overload the '+' operator. The function will add each element of the first queue with the corresponding element from the other queue.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
What is the value of arysize after executing the following code:
Answer:
int testary[] = { 1,5,8,9,6,7,3,4,2,0 };
int arysize
=
sizeof(testAry) / sizeof(testAry[5]);
To pass an object of type struct or class to a function as an argument,
which of the following is true? (Select all that apply)
a. You can pass it by reference
b. You can pass it by value
c. You can pass it by value but not by reference
d. You can pass it by reference but not by value
e. None of the answers
Based on the code of contiguous queue, create a non-member function
(friend) that uses operator overloading to overload the '+' operator. The
function will add each element of the first queue with the corresponding
element from the other queue.
1111011
01010
Transcribed Image Text:What is the value of arysize after executing the following code: Answer: int testary[] = { 1,5,8,9,6,7,3,4,2,0 }; int arysize = sizeof(testAry) / sizeof(testAry[5]); To pass an object of type struct or class to a function as an argument, which of the following is true? (Select all that apply) a. You can pass it by reference b. You can pass it by value c. You can pass it by value but not by reference d. You can pass it by reference but not by value e. None of the answers Based on the code of contiguous queue, create a non-member function (friend) that uses operator overloading to overload the '+' operator. The function will add each element of the first queue with the corresponding element from the other queue. 1111011 01010
Expert Solution
size of arysize and object passing

output : 1

this is because sizeof(arysize) represent the size of first element and it is divided by element at 5th index , where size of every element in array is same so when they divide gives 1;

object pass to function:

C++ always gives you the choice: All types T (except arrays, see below) can be passed by value by making the parameter type T, and passed by reference by making the parameter type T &, reference-to-T.

When the parameter type is not explicitly annotated to be a reference (type &myVariable), it is always passed by value regardless of the specific type. For user-defined types too (that's what the copy constructor is for). Also for pointers, even though copying a pointer does not copy what's pointed at.

Arrays are a bit more complicated. Arrays cannot be passed by value, parameter types like int arr[] are really just different syntax for int *arr. It's not the act of passing to a function which produces a pointer from an array, virtually every possible operation (excluding only a few ones like sizeofdoes that. One can pass a reference-to-an-array, but this explicitly annotated as reference: int (&myArray)[100].

 

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education