Skip to main content
Java has other kinds of overloading.
Source Link

We should edit the wiki to include the other languages. The new keyword in those languages looks like the new keyword in C++, because C++ is a popular language that influenced other languages.

C++ new is a keyword. I can't declare a variable int new;, just as I can't declare int using; or int while; in C++. There is an operator keyword that overloads operators, as in operator + or operator <<. C++ also uses operator to overload new, as operator new. So we also say that C++ new is an operator. The new keyword and the new operator are the same thing; there is no difference.

Other languages, like Java, may simplify new. Java has no overloading of new, so there is no operator new syntax to overload it. Java new is still an operator, because the operator looks the same in Java and C++:

Thing *x = new Thing(y);  // C++
Thing x = new Thing(y);   // Java

probably has more C++ questions than Java questions, because C++ has more complications (like overloading and placement new) that don't exist in Java. I see 7 highlighted questions under the tag info; 5 are C++ but 2 are other languages:

  1. Why should C++ programmers minimize use of 'new'?
  2. Do the parentheses after the type name make a difference with new?
  3. Passing arguments to C# generic new() of templated type
  4. Using "Object.create" instead of "new"
  5. Why does the use of 'new' cause memory leaks?
  6. C++ new int[0] -- will it allocate memory?
  7. Why would one replace default new and delete operators?

All 7 questions have language tags, so we know if the question is about C++ or some other language. This allows C++ to share with other languages. JavaScript new also sets the prototype of the object, which raises questions that don't exist in C++ or Java. Stack Overflow isn't only for C++.

Perl also had the new operator:

use Math::BigInt;
my $bn = new Math::BigInt('42');

This new isn't a keyword, but it looks like the operator in C++. This syntax has some problems and Perl now discourages it, but people do ask questions about it.

We should edit the wiki to include the other languages. The new keyword in those languages looks like the new keyword in C++, because C++ is a popular language that influenced other languages.

C++ new is a keyword. I can't declare a variable int new;, just as I can't declare int using; or int while; in C++. There is an operator keyword that overloads operators, as in operator + or operator <<. C++ also uses operator to overload new, as operator new. So we also say that C++ new is an operator. The new keyword and the new operator are the same thing; there is no difference.

Other languages, like Java, may simplify new. Java has no overloading, so there is no operator new syntax to overload it. Java new is still an operator, because the operator looks the same in Java and C++:

Thing *x = new Thing(y);  // C++
Thing x = new Thing(y);   // Java

probably has more C++ questions than Java questions, because C++ has more complications (like overloading and placement new) that don't exist in Java. I see 7 highlighted questions under the tag info; 5 are C++ but 2 are other languages:

  1. Why should C++ programmers minimize use of 'new'?
  2. Do the parentheses after the type name make a difference with new?
  3. Passing arguments to C# generic new() of templated type
  4. Using "Object.create" instead of "new"
  5. Why does the use of 'new' cause memory leaks?
  6. C++ new int[0] -- will it allocate memory?
  7. Why would one replace default new and delete operators?

All 7 questions have language tags, so we know if the question is about C++ or some other language. This allows C++ to share with other languages. JavaScript new also sets the prototype of the object, which raises questions that don't exist in C++ or Java. Stack Overflow isn't only for C++.

Perl also had the new operator:

use Math::BigInt;
my $bn = new Math::BigInt('42');

This new isn't a keyword, but it looks like the operator in C++. This syntax has some problems and Perl now discourages it, but people do ask questions about it.

We should edit the wiki to include the other languages. The new keyword in those languages looks like the new keyword in C++, because C++ is a popular language that influenced other languages.

C++ new is a keyword. I can't declare a variable int new;, just as I can't declare int using; or int while; in C++. There is an operator keyword that overloads operators, as in operator + or operator <<. C++ also uses operator to overload new, as operator new. So we also say that C++ new is an operator. The new keyword and the new operator are the same thing; there is no difference.

Other languages, like Java, may simplify new. Java has no overloading of new, so there is no operator new syntax to overload it. Java new is still an operator, because the operator looks the same in Java and C++:

Thing *x = new Thing(y);  // C++
Thing x = new Thing(y);   // Java

probably has more C++ questions than Java questions, because C++ has more complications (like overloading and placement new) that don't exist in Java. I see 7 highlighted questions under the tag info; 5 are C++ but 2 are other languages:

  1. Why should C++ programmers minimize use of 'new'?
  2. Do the parentheses after the type name make a difference with new?
  3. Passing arguments to C# generic new() of templated type
  4. Using "Object.create" instead of "new"
  5. Why does the use of 'new' cause memory leaks?
  6. C++ new int[0] -- will it allocate memory?
  7. Why would one replace default new and delete operators?

All 7 questions have language tags, so we know if the question is about C++ or some other language. This allows C++ to share with other languages. JavaScript new also sets the prototype of the object, which raises questions that don't exist in C++ or Java. Stack Overflow isn't only for C++.

Perl also had the new operator:

use Math::BigInt;
my $bn = new Math::BigInt('42');

This new isn't a keyword, but it looks like the operator in C++. This syntax has some problems and Perl now discourages it, but people do ask questions about it.

Source Link

We should edit the wiki to include the other languages. The new keyword in those languages looks like the new keyword in C++, because C++ is a popular language that influenced other languages.

C++ new is a keyword. I can't declare a variable int new;, just as I can't declare int using; or int while; in C++. There is an operator keyword that overloads operators, as in operator + or operator <<. C++ also uses operator to overload new, as operator new. So we also say that C++ new is an operator. The new keyword and the new operator are the same thing; there is no difference.

Other languages, like Java, may simplify new. Java has no overloading, so there is no operator new syntax to overload it. Java new is still an operator, because the operator looks the same in Java and C++:

Thing *x = new Thing(y);  // C++
Thing x = new Thing(y);   // Java

probably has more C++ questions than Java questions, because C++ has more complications (like overloading and placement new) that don't exist in Java. I see 7 highlighted questions under the tag info; 5 are C++ but 2 are other languages:

  1. Why should C++ programmers minimize use of 'new'?
  2. Do the parentheses after the type name make a difference with new?
  3. Passing arguments to C# generic new() of templated type
  4. Using "Object.create" instead of "new"
  5. Why does the use of 'new' cause memory leaks?
  6. C++ new int[0] -- will it allocate memory?
  7. Why would one replace default new and delete operators?

All 7 questions have language tags, so we know if the question is about C++ or some other language. This allows C++ to share with other languages. JavaScript new also sets the prototype of the object, which raises questions that don't exist in C++ or Java. Stack Overflow isn't only for C++.

Perl also had the new operator:

use Math::BigInt;
my $bn = new Math::BigInt('42');

This new isn't a keyword, but it looks like the operator in C++. This syntax has some problems and Perl now discourages it, but people do ask questions about it.