Why we need new operator in java at the time of object
declaration and why not in c++?

Answer Posted / anuja joshi

The major difference between Java and C++ is the behavior of object variables. In C++, object variables hold values, not object references. Note that the new operator is never used when constructing objects in C++. You simply supply the construction parameters after the variable name.

Point p(1, 2); /* construct p */

If you do not supply construction parameters, then the object is constructed with the default constructor.

Time now; /* construct now with Time::Time() */

This is very different from Java. In Java, this command would merely create an uninitialized reference. In C++, it constructs an actual object.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how do u handle table control inbdc explain the process in steps iwant the answer in urgent please forward this even i know how to explain there

1751


Is class is a abstract datatype in java?

1451


public static void main(String args[]) describe it

1575


how can we implement locks in plsql?

1790


WHAT IS THE MEANING OF CONSTANT ...EXEEDS LENGTH LIMIT WHILE COPYING FROM PS FILE TO KSDS

1515






purpose of abstraction and interface

1528


If i have a dataset queried from Sql and I would like to insert the dataset into a specific node in an xml document how do I do this

1701


what is radio button? Plz show code this! how will select radio buttons to go next window Forms? Supose o radio button1 o radio button2 o radio button3 o radio button4 how will coding this? Plz explain this!

2901


can any one suggestion me present which course(except java,.net) has huge demand in the market?

1617


I want Ada programming language books. Could anyone post me any link for that?

2947


what are all the validation we need to perform in data stage?

1944


how to convert the data from HTML file to SAS dataset?

2189


the systematic access of small computers in a distributed data processing system is referred as?

2720


Given an array of size n, containing every element from 1 to n+1, except one. Find the missing element.

643


< DL Compact > tag is used for

1545