473,385 Members | 1,282 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,385 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 1858
"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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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

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.