473,387 Members | 1,420 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

multiple 'new' at single line

Hi, people.

Can anybody explain me "multiple 'new' at single line"
behavior. Consider:

p::p(void*);
p::p(void*,void*);

new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));

Will it be either

1.
new F p(*)
new E p(*)
new D p(*)
new C p(*)
new B p(*)
new A

and
2.
new B p(*)
new D p(*)
new E p(*)
new C p(*)
new F p(*)
new A p(*)

or
3.

new E
new D
new F
new C
new B
p(*)
p(*)
p(*)
p(*)
p(*)
new A

Does C++ guarantee that never can be like upper
case 3 (more than one "new" befor "p(*)").

Do we need to create temp storages:

const p tmp1(new F);
const p tmp2(new E);
const p tmp3(new D);
const p tmp4(new C(tmp3,tmp2));
const p tmp5(new B);
new A(tmp5,tmp4,tmp1);

Jan 1 '07 #1
3 1859
"Grizlyk" <gr******@yandex.ruwrote:
Hi, people.

Can anybody explain me "multiple 'new' at single line"
behavior. Consider:

p::p(void*);
p::p(void*,void*);

new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));
The only order guarantee you have with the above is that the B, D, E and
F object will be created first (in any order); that C will be created
after D and E; and that B through F will all be created before A.
Outside of that, there are no order guarantees.
Jan 2 '07 #2

Daniel T. wrote:
new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));

The only order guarantee you have with the above is that the B, D, E and
F object will be created first (in any order); that C will be created
after D and E; and that B through F will all be created before A.
Outside of that, there are no order guarantees.
I do not understand, can be optimized or no like this:

compiled_tmp1=new D,
compiled_tmp2=new E,
compiled_p1=p(compiled_tmp1),
compiled_p2=p(compiled_tmp2),
new c(compiled_p1, compiled_p2);

Jan 2 '07 #3
"Grizlyk" <gr******@yandex.ruwrote:
Daniel T. wrote:
new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));
The only order guarantee you have with the above is that the B, D, E and
F object will be created first (in any order); that C will be created
after D and E; and that B through F will all be created before A.
Outside of that, there are no order guarantees.

I do not understand, can be optimized or no like this:

compiled_tmp1=new D,
compiled_tmp2=new E,
compiled_p1=p(compiled_tmp1),
compiled_p2=p(compiled_tmp2),
new c(compiled_p1, compiled_p2);
Yes, it can be done like that. It can also be done like this:

compiled_tmp1=new D,
compiled_p1=p(compiled_tmp1),
compiled_tmp2=new E,
compiled_p2=p(compiled_tmp2),
new c(compiled_p1, compiled_p2);

or like this:

compiled_tmp2=new E,
compiled_p2=p(compiled_tmp2),
compiled_tmp1=new D,
compiled_p1=p(compiled_tmp1),
new c(compiled_p1, compiled_p2);

or like this:

compiled_tmp2=new E,
compiled_tmp1=new D,
compiled_p1=p(compiled_tmp1),
compiled_p2=p(compiled_tmp2),
new c(compiled_p1, compiled_p2);

Or any of a few other orders I expect.
Jan 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
4
by: Neo Geshel | last post by:
Greetings I am using VB in my ASP.NET project that uses an admin web site to populate a database that provides content for a front end web site. I am looking for a way to use replace() to...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
6
by: Bill | last post by:
Hi I am trying to get my listbox items to print if they stream past the one page mark. my code is working for one page of information (if the e.hasmorepages) is not there. But I am having...
47
by: Mark | last post by:
why doesn't .NET support multiple inheritance? I think it's so silly! Cheers, Mark
0
by: Grizlyk | last post by:
Hi, people. Can anybody explain me "multiple 'new' at single line" behavior. Consider: p::p(void*); p::p(void*,void*); new A( p(new B), p( new C(p(new D), p(new E)) ), p(new F));
3
by: Richard S | last post by:
CODE: ASP.NET with C# DATABASE: ACCES alright, im having a problem, probably a small thing, but i cant figure out, nor find it in any other post, or on the internet realy (probably cuz i wouldnt...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.