Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7515165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:43:04+00:00 2026-05-30T00:43:04+00:00

Consider this code : int main() { int i(6); //this will result in i==6,but

  • 0

Consider this code :

int main()
{
    int i(6); //this will result in i==6,but consider next initializations

    int j(int()); 

    T * p2 = new T(); 
}

I find that the value of j is 1, but this should be 0 because int() is a temporary with value equal to 0.

Also, the syntax for the new operator is new typename, but here T() will be a temporary object instead of a type name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:43:05+00:00Added an answer on May 30, 2026 at 12:43 am
    int j(int()); 
    

    This doesn’t declare an object. Instead it declares a function which takes a function as argument, and returns int. The type of the function which it takes as argument is this :

     typedef int (*funtype)();
    

    That, is, a function which returns int, and takes nothing as argument.

    The parsing of such a declaration is commonly known as:

    • Most vexing parse
    • Most vexing parse: why doesn't A a(()); work?

    And in the new syntax, T() doesn’t create a temporary object. That is not how it is to be seen. Instead, you’ve to look at the entire expression new T() which first allocates memory for an object of type T, and then construct the object in that memory. If T is a user-defined type, then it calls the default constructor to construct the object, after allocating the memory.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this code: int main() { int e; prn(e); return 0; } void prn(double
Please consider this code: template<typename T> char (&f(T[1]))[1]; template<typename T> char (&f(...))[2]; int main()
Consider this code: void res(int a,int n) { printf(%d %d, ,a,n); } void main(void)
I have a trouble with references. Consider this code: void pseudo_increase(int a){a++;} int main(){
Consider this code: #include <iostream> template<class C> struct time { }; int main() {
Consider this code: #include <iostream> int main() { int iTemp = 0; iTemp +=
Let’s consider this very short snippet of code: #include <stdlib.h> int main() { char*
Consider this code: #include <iostream> using namespace std; int main() { bool lock =
Consider this code: int x = 17; int y = 013; System.out.println(x+y = +
Consider this code (Java, specifically): public int doSomething() { doA(); try { doB(); }

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.