What is the difference between new() and malloc()?
Answers were Sorted based on User's Feedback
Answer / nashiinformaticssolutions
• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / nashiinformaticssolutions
o new initializes the object and calls its constructor.
o malloc allocates memory but does not call constructors.
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / glibwaresoftsolutions
• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.
| Is This Answer Correct ? | 0 Yes | 0 No |
• new: Calls constructor, returns an object of the correct type.
• malloc(): Does not call constructor, returns void*.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is the difference between Pointer and a Reference? When you would use them?
What is format for defining a structure?
Which is the best c++ software?
What is the use of volatile keyword in c++? Give an example.
write a program that takes two numbers from user that prints the smallest number
What is an Iterator class?
Describe private, protected and public?
1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main() { int v=10; afunction(&v); cout<<v; } a) Outputs 12 b) Outputs 10 c) Outputs the address of v
What are the basics of classifying different storage types, why?
2 Answers Astergate, Symphony,
How can I improve my c++ skills?
What is near, far and huge pointers? How many bytes are occupied by them?
Explain stack & heap objects?