Multiple Choice
Multiple Choice Section 4.1 Pointers and Dynamic Memory |
int *p; int i; int k; i = 42; k = i; p = &i;After these statements, which of the following statements will change the value of i to 75?
int i = 42; int j = 80; int *p1; int *p2; p1 = &i; p2 = &j; *p1 = *p2; cout << i << j << endl;What numbers are printed by the output statement?
int i = 1; int k = 2; int *p1; int *p2; p1 = &i; p2 = &k; p1 = p2; *p1 = 3; *p2 = 4; cout << i;
int i = 1; int k = 2; int* p1; int* p2; p1 = &i; p2 = &k; p1 = p2; *p1 = 3; *p2 = 4; cout << k;
int i = 1; int k = 2; int* p1; int* p2; p1 = &i; p2 = &k; *p1 = *p2; *p1 = 3; *p2 = 4; cout << i;
Multiple Choice Section 4.2 Pointers and Arrays as Parameters |
void goop(int z[ ]); int x[10];Which is the correct way to call the goop function with x as the argument:
void goo(int* x) { *x = 1; }Suppose that a is an int* variable pointing to some integer, and *a is equal to zero. What is printed if you print *a after the function call goo(a)?
Multiple Choice Section 4.3 The Bag ADT with a Dynamic Array |
void quiz( ) { bag::size_type i; // Line 1 bag b; // Line 2 b.insert(42); // Line 3 i = b.size( ); // Line 4 cout << i; // Line 5 }When is the bag's dynamic array allocated?
void quiz( ) { bag::size_type i; // Line 1 bag b; // Line 2 b.insert(42); // Line 3 i = b.size( ); // Line 4 cout << i; // Line 5 }When is the bag's dynamic array returned to the heap?
void operator =(const foo& source);In an assignment statement a = b, what will be the actual argument for the parameter source?
Multiple Choice Section 4.4 Prescription for a Dynamic Class |
Multiple Choice Section 4.5 The String ADT |
`Hey,
Note: Brother in case of any queries, just comment in box I would be very happy to assist all your queries
1)
*p=75
OPTION D IS CORRECT
2)
OPTION D IS CORRECT
3)
OPTION A IS CORRECT
4)
OPTION D IS CORRECT
Note: Brother according to HomeworkLib's policy we are only allowed to answer first 4 parts if there are many. So, I request you to post other as separate posts.
Kindly revert for any queries
Thanks.
Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...
1.Suppose that the goop function from the previous question changes the value of z[1]. Does this change effect the value of the actual argument? A. Yes B. No 2.Here is a function declaration: void goo(int* x) { *x = 1; } Suppose that a is an int* variable pointing to some integer, and *a is equal to zero. What is printed if you print *a after the function call goo(a)? A. 0 B. 1 C. address of a D. address...
C++ problem with dynamic arrays is that once the array is created using the new operator the size cannot be changed. For example, you might want to add or delete entries from the array similar to the behavior of a vector. This project asks you to create a class called DynamicStringArray that includes member functions that allow it to emulate the behavior of a vector of strings. The class should have: A private member variable called dynamicArray that references a...
please write in c++. 4 Derived class JPG 4.1 Class declaration • The class JPG inherits from File and is a non-abstract class. 1. Hence objects of the class JPG can be instantiated. 2. To do so, we must override the pure virtual function clone() in the base class. • The class declaration is given below. class JPG : public File { public: JPG(const std::string& n, int n, int w, const double rgb()) : File(...) { // ... } *JPG()...
Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3 (using a fixed array and a typedef statement) what steps were necessary for changing from a bag of integers to a bag of double values? A. Change the array declaration from int data[CAPACITY] to double data[CAPACITY] and recompile. B. Change the int to double in the typedef statement and recompile. C. Round each double value to an integer before putting it in the bag....
C++ 1. The copy constructor is used for one the following scenarios: I. Initialize one object from another of the same type. II. Copy an object to pass it as argument to a function. III. Copy an object to return it from a function. Read the following program and answer questions (20 points) #include <iostream> using namespace std; class Line public: int getLength( void); Line( int len // simple constructor Line( const Line &obj) 1/ copy constructor Line (); //...
This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...
C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...
C++ Assignment - Only Implementation file( VectorDouble.cpp file) required. The header file is already given. Please help, thumbs up guaranteed. Chapter 8 discussed vectors, which are like arrays that can grow in size. Suppose that vectors were not defined in C++. Define a class called VectorDoublethat is like a class for a vector with base type double. Your class VectorDoublewill have a private member variable for a dynamic array of doubles. It will also have two member variables of type...
Introduction: One of the most important uses of pointers is for dynamic allocation of memory. In C++ there are commands that let the user request a chunk of memory from the operating system, and use this memory to store data. There are also commands to return memory back to the O/S when the program is finished using the data. In this lab, we will explore some of the things that can go wrong when using dynamic memory and discuss how...
In C++ and comment so I UNDERSTAND Implement a class named DynamicArray that has the following members: A pointer to hold a dynamically allocated array, of type int. A member variable to hold the size of the array. A default constructor, which will allocate an array of size 10 A parameterized constructor, which takes a size and use the size to allocate array. A copy constructor, which performs deep copy. A copy assignment operator, which performs deep copy and supports...