1) Short Answer: a) Explain why a reference cannot be NULL (as opposed to a pointer...
TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes P1 to point to the memory location 1001. ANSWER: T 2. When you return a dynamic array to the freestore, you must include the number of elements in the array 3. You can assign an array to a pointer variable. 4. The size of dynamic arrays must be declared at compile time. 5. int *pl; declares a static variable. ANSWER: F ANSWER: F ANSWER:...
MUST USE C++ PLEASE READ THE QUESTION CAREFULLY!! ADD COMMENTS/EXPLAIN Question 1: Template Function with Pointer Arguments Design and implement a template function, called swapt(T *p1, T *p2), which takes two parameters with the same generic data type. The function swaps the values of these two parameters. Test this function in the following main( ) : int main( ) { int x = 30, y = 40; swapt(&x, &y); cout << “x = “ << x...
6. (Short answer) The C++ code below is very close to working, but, as written, won't compile. When trying to compile, the compiler generates a number of errors similar to "cout' was not declared in this scope." Respond to the prompts below about the code.(20 points, 5 points each) #include <iostream> void FindMax(int a, int b, int& max) { if (a > b) max = a; else { max = b; } int main() { int num1 = 0; int...
Using C++ in Visual Studios
Rewrite the code to use a Stack instead of a Queue. You will
need to think about the differences in the Stack and Queue. Think
about how they operate and how the nodes may differ.
Modify the code as necessary.
You will need to push to the Stack, pop from the Stack, peek at
the Stack. You will need a member functions like in the example
code. Your program will need to show that everything...
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...
Part 5: C++ Programming (25/100) 13) (5 marks) Explain the difference between a call by value and a call by reference. 14) (5 marks) What value of y will be displayed when the following ++ program is run: tinclude <iostream int main) double x 3.0, y: y1/3 x16.0) std::cout <<y<"n" return (0): Show the details step by step as how the computer would perform the calculation and justify your resuits. Also, what will the data type of y be? For...
1. Answer questions (a) through (d) for the mutant on line 6 in the method sum(). Sum values in an array Oparam x array to sum *Oreturn sum of values in x Othrows NullPointerException if x is null public static int sum(int[] x) 2. 3. int -0 4. for (int i-0; ǐ < x·length; İ++) } s=s+x[1]; 6 6 11s-s-x(4]://AOR 7. 8 return s (a) If possible, find test inputs that do not reach the mutant. (2 pts.) (b) If...
C++ 1. Please use attached script for your reference to create the node structure and a linked list class, say LinkedList, that has the following basic member methods: constructor, destructor//IMPORTANT, display(), add_node(). 2. Please implement the following additional member methods: Please feel free to change T with any data type you'd like to use for your node stricture's data type. -- addFirst(T data) // Adds an node with data at the beginning of the list -- pop() //...
C++ 1. Please use attached script for your reference to create the node structure and a linked list class, say LinkedList, that has the following basic member methods: constructor, destructor//IMPORTANT, display(), add_node(). 2. Please implement the following additional member methods: Please feel free to change T with any data type you'd like to use for your node stricture's data type. -- addFirst(T data) // Adds an node with data at the beginning of the list -- pop() //...
Please answer all the questions thank you
1) (Classes – 20 Points) Consider the following class declaration for Time to complete the questions below: DO NOT WRITE MORE THAN ASKED FOR. class Time private: int hours; int minutes; public: Time(); Time (int , int m = 0); void addMin(int m); void addHr(int h); void reset(int h = 0, int m = 0); Time operator+(const Time & t) const; Time operator-(const Time & t) const; Time operator*(double n) const; friend Time...