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

In an customer exit (include Z) program, only the last record is getting fetched. The exit is getting called after pressing save button. What to write for fetching the first record ? Before saved to a SAP table how can i call all these records in an itab in the exit ?

1517


Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren?t present.

629


qtp 9.2 14 days demo version was expired.I uninstalled how to reinstall this again

2356


In project we have Documentation phase also,in that what is micro and macro designing?

1427


what is the last ant version you worked?how to get it

1465






what are the missinschema properties and should we pass primary key in select command

1422


when we use mantis? how learn mantis?

1693


what are the differences between CONS, LIST, and APPEND

4764


i am getting the error while compiling my cics program with including db2 dclgen member it is showing that ur dclgen member not including and all the host variables are undeclared

1097


what is the system development cycle

1269


how to add Servlet-api.jar file into eclipse 3.3.2 ?

4061


what is meant by life cycle of a business

1701


write algo for cobol program whichuse three flat file to extract some specific information 8 marks mainframe

1564


Any real time example of O2C process from taking order till creating invoice.

1791


Q2. A memory location has physical address D5687h. Compute: a. The offset address if the segment number is D445h. b. The segment number if the offset address is B577h.

1633