473,385 Members | 2,210 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.

why Visual Studio can not optimize the initialization code?

Hello everyone,
Why Visual Studio compiler can not optimize in this case? I think this
case is almost the same as sample 1, why compiler can optimize sample
1 but can not optimze sample 2?

(sample 2, http://msdn2.microsoft.com/en-us/lib...57(vs.80).aspx)

Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. class A {
  3. public:
  4. A() {printf ("A: I am in constructor\n");i = 1;}
  5. ~A() { printf ("A: I am in destructor\n"); i = 0;}
  6. A(const A& a) {printf ("A: I am in copy constructor\n"); i = a.i;}
  7. int i, x, w;
  8. };
  9. class B {
  10. public:
  11. A a;
  12. B()  { printf ("B: I am in constructor\n");}
  13. ~B() { printf ("B: I am in destructor\n");}
  14. B(const B& b) { printf ("B: I am in copy constructor\n");}
  15. };
  16. A MyMethod()
  17. {
  18. B* b = new B();
  19. A a = b->a;
  20. delete b;
  21. return (a);
  22. }
  23. int main()
  24. {
  25. A a;
  26. a = MyMethod();
  27. }
  28.  

thanks in advance,
George
Dec 19 '07 #1
1 1316
George2 wrote:
Hello everyone,
Why Visual Studio compiler can not optimize in this case?
Optimization is beyond the C++ language definition. Further, specific tools
are not discussed here. You should ask in a newsgroup about Visual Studio.
I think this case is almost the same as sample 1, why compiler can
optimize sample 1 but can not optimze sample 2?

(sample 2, http://msdn2.microsoft.com/en-us/lib...57(vs.80).aspx)
This web page is severely broken. It doesn't work in my browser, and the W3
validator reports 63 errors.

Dec 19 '07 #2

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

Similar topics

1
by: jmd | last post by:
Hello. I have downloaded and installed Visual Studio 2005 February CTP -- Professional Edition (English) from msdn. All works fine (with a few bugs) except the Quickstarts. The Quickstarts install...
1
by: Chris Morse | last post by:
Does anyone know how to profile a VB.NET application? In the VS.NET 2003 docs, I found this: (BEGIN DOC COPY) "A code profiler is a software tool, implemented as a DLL, which is called by...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
3
by: karlag92 | last post by:
We have a very large C# winforms client application that is constructed as a single solution currently with 75 projects. We're currently using VS 2003 but will upgrade to 2005 some time next year....
4
by: George2 | last post by:
Hello everyone, Why Visual Studio compiler can not optimize in this case? I think this case is almost the same as sample 1, why compiler can optimize sample 1 but can not optimze sample 2? ...
4
by: George2 | last post by:
Hello everyone, Why visual studio does not optimize constructor in this case? I do not understand what the MSDN mentioned, if use different named object, compiler can not optimize. Why? ...
4
by: maria | last post by:
I have an array, string data, which produces the error "Too many initializers". Each one of the 248 rows has 5 items with a maximum total length of 173 characters. I am using Visual Studio...
2
by: Z.K. | last post by:
I was wondering if someone could tell me why I get this message and how to prevent it. If I hit continue, it runs fine, but want to know what I am doing wrong so I won't get this error in the...
2
Markus
by: Markus | last post by:
I recently installed Visual Studio 2008 Professional. On the initial install it gave me a list of options, something to do with optimizing Visual Studio. It gave you the option to optimize it for C#,...
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.