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 project we have Documentation phase also,in that what is micro and macro designing?

1528


Can we write a method in JSP.If so how?

1568


how can i create report in abap to insert data in table pa0002 using insert command

1823


I have try to write a record in a TDQ from a fle.... what are the steps to do... can anybody plz come with a solution

2311


I am looking for NIC Sample papers or any patern of questions/ syllabus plz, send me on hamid.khan135@yahoo.in Regard

1625






iam confused to choose among testing, .net and java can anybody help me????????

1710


what are the differences between CONS, LIST, and APPEND

4855


what is the current salary package in India for a lamp programmer

1969


what is best way to create a Thread class & why?

1693


how to remove header and footer in jcl using sort utility

5222


When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)

809


How to connect the .accdb database file of microsoft access to the Visual Basic 6.0 forms?

3814


What is the difference between DECISION COVERAGE(DC) and MODIFIED CONDITION/DECISION COVERAGE(MCDC)?

1873


THE CHANNEL IN DATA COMMUNICATION CAN BE?

1656


can u send some model papers how computer awareness questions are asked in goverment jobs(oriental insurance)to my mail id me.priyankapadma@rediff.com

2039