Question

What does the following statement do? Myobject * obj1 = new Myobject; A. nothing, it is...

What does the following statement do?

Myobject * obj1 = new Myobject;

A. nothing, it is meaningless code.

B. deletes Myobject.

C. sets the obj1 pointer to NULL.

D. allocates space on the heap for obj1 and returns a pointer to it.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Question:
What does the following statement do?
Ans: D. allocates space on the heap for obj1 and returns a pointer to it.

Let's check with the options:
A nothing, it is meaningless code is not true because it is creating a pointer of type Myobject.
B. deletes Myobject is also false because it is not deleting the MYobject
C. sets the obj1 pointer to NULL.
To set the obj1 pointer to NULL, we can do like obj1=NULL.
D. allocates space on the heap for obj1 and returns a pointer to it.
This is true, we are allocating the space on the heap for the obj1 and return value is a pointer to it.

(Feel free to drop me a comment, If you need any help)

Hope this Helps!!!
Please upvote as well, If you got the answer?
If not please comment, I will Help you with that...

Add a comment
Know the answer?
Add Answer to:
What does the following statement do? Myobject * obj1 = new Myobject; A. nothing, it is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Hi all, I need help to do a project based on C++ smart pointers. I have...

    Hi all, I need help to do a project based on C++ smart pointers. I have to implement the class template my_unique_ptr which is a pointer management class template. Also, it's required to implement the following public methods: a. Default constructor that initializes the object to point to nullptr. b. Constructor that takes a pointer Type * as a parameter and sets the object to point there. We say that the newly created object takes ownership of the pointed memory....

  • Implement the class MaxHeapPriorityQueue as a heap with the following operations: • MaxHeapPriorityQueue() creates a new...

    Implement the class MaxHeapPriorityQueue as a heap with the following operations: • MaxHeapPriorityQueue() creates a new heap that is empty. It needs no parameters and returns nothing. Note that as discussed in the video lecture, the index range of the array implementation of a heap is 1:n, NOT 0:n-1 • parent(index) returns the value of the parent of heap[index]. index is between 1 and the size of the heap. If index<=1 or index>size of the heap, it returns None •...

  • circle the correct answer please. Please reply Asap. 8. What does the following jQuery code do?...

    circle the correct answer please. Please reply Asap. 8. What does the following jQuery code do? s ("inage").attr(are", imagoURL) a Gets the value of the sre aribute for the element with an id of "image" and stores it in a variable named imageURL Sets the value of the sre attribute for the element with an id of "image" to the value in a variable named imageURL Gets the values of the sre attribute for each element with a class of...

  • C++ code 8. (10 pts) a) Write a statement linked list to change the following inked...

    C++ code 8. (10 pts) a) Write a statement linked list to change the following inked list into a circular the 0 Data Next FrontA b) What does FIFO stands for? below and return c) Write statements to delete the 3d node from the doubly linked list its storage to the heap of available space. Prev Data Next Fro 0 A 4 3 2

  • What does the instruction jal do? It populates the PC with the address given by the...

    What does the instruction jal do? It populates the PC with the address given by the input. It saves the current PC (plus 4 bytes) to the $ra register and the populates the PC with the address given by the input. It populates the PC counter with the word currently stored in the $ra register. It allocates the input number of bytes (provided as an immediate value) onto the stack. 1 points    QUESTION 6 What is a function pointer?...

  • 1. What does a Java compiler do? Select one: a. Runs Java programs b. Translates byte...

    1. What does a Java compiler do? Select one: a. Runs Java programs b. Translates byte code in ".class" files into machine language c. Translates source code in ".class" files into machine language d. Translates source code in ".java" files into Java byte code in ".class" files e. Translates source code in ".java" files into machine language 2. A subclass will _____ one superclass. Select one: a. abstract b. extend c. implement d. inherit e. override 3. Consider the following...

  • What does the following function f do? The parameter r is the root of a Binary...

    What does the following function f do? The parameter r is the root of a Binary Search Tree? DO NOT JUST EXPLAIN THE CODE. DO NOT JUST EXPLAIN THE SYNTAX OF THE CODE. int f(Node* r) { if (r.left == NULL && r.right==NULL) return 0; else return 1+f(r.left)+f(r.right); }

  • Given the following class: class Q2 { private int a; private int b; private int c;...

    Given the following class: class Q2 { private int a; private int b; private int c; public void setA(int a){this.a = a; } public void setB(int b){this.b = b;} public void setc(int c){this.c = c;} public int geta(){return a; } public int gets(){return b;} public int getc(){return c;} public int m1(int a, int b){ return a + b; public boolean m2 (int x, int y){ return m1(x, y) + x + y < 10; What is the output of the...

  • 1) What does PCR stand for and what does it do? a. Polymerase Chain Reaction; PCR...

    1) What does PCR stand for and what does it do? a. Polymerase Chain Reaction; PCR deletes DNA b. Polymerase Copying Repeats; PCR amplifies DNA c. Polymerase Copying Releats; PCR deletes DNA d. Polymerase Chain Reaction; PCR amplifies DNA 2) During gel electrophoresis, the DNA fragments are separated by ____ a. charge b. DNA fragments cannot be separated c. color d. size 3) Primers are a. double stranded DNA oligonucleotide (fragment) b. double stranded RNA oligonucleotide (fragment) c. single stranded...

  • What does the following git command do? git stash –-merge a. It will stash all the...

    What does the following git command do? git stash –-merge a. It will stash all the merges b. It stashes current changes c. Nothing. It throws an error out. d. Two of the above are correct.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT