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/library/ms364057(vs.80) .aspx) -
#include <stdio.h>
-
class A {
-
public:
-
A() {printf ("A: I am in constructor\n");i = 1;}
-
~A() { printf ("A: I am in destructor\n"); i = 0;}
-
A(const A& a) {printf ("A: I am in copy constructor\n"); i = a.i;}
-
int i, x, w;
-
};
-
class B {
-
public:
-
A a;
-
B() { printf ("B: I am in constructor\n");}
-
~B() { printf ("B: I am in destructor\n");}
-
B(const B& b) { printf ("B: I am in copy constructor\n");}
-
};
-
A MyMethod()
-
{
-
B* b = new B();
-
A a = b->a;
-
delete b;
-
return (a);
-
}
-
int main()
-
{
-
A a;
-
a = MyMethod();
-
}
-
thanks in advance,
George
4 1180
Optimization is an advanced topic. You need no be concerned with this until after your C++ program has been coded and debugged. And maybe not even then.
I have been using C++ for 17 years and have not yet needed to optimize. My applications just didn't warrant it.
I would post this question again when you have about 5 yrs C++ experience.
Hi weaknessforcats ,
I have programmed with C++ for more than 5 years, including the time in school. Any ideas for the question. :-)
Optimization is an advanced topic. You need no be concerned with this until after your C++ program has been coded and debugged. And maybe not even then.
I have been using C++ for 17 years and have not yet needed to optimize. My applications just didn't warrant it.
I would post this question again when you have about 5 yrs C++ experience.
regards,
George
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Noulouk |
last post by:
Hi,
I build an add-in for Visual Studio 2005.
I use the wizzard, I fixed the bug with envdte reference and build my
project immediately after the wizzard.
All seems to work, the add-in is shown in add-in Manager window, but no
button appears in Tools window.
Here is my code:
namespace MyAddinTest
|
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 without problems.
I have 2 questions :
1. When I launch the Quickstarts, I only see :
--------------------------------------------------------------------------------
Microsoft .NET Framework SDK QuickStart Tutorials
|
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 the runtime system during the execution of an image. The
profiler receives notifications each time a function is entered or
exited, as well as when other events occur that are of interest to the
|
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 page "How to: Connect to Data in an Access Database"
|
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.
We've noticed that Visual Studio is terribly inefficient about a lot of
things, and my testing with 2005 seems to indicate those problems may
actually be worse there.
On average, it can take 3 to 5 minutes to simply open the solution
while...
| |
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?
(sample 2, http://msdn2.microsoft.com/en-us/library/ms364057(vs.80).aspx)
|
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?
http://msdn2.microsoft.com/en-us/library/ms364057(vs.80).aspx
|
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 6.0. Should I allocate memory
for this array to avoid the error? If the answer is "Yes", would you
please be kind enough to tell me how?
|
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 future. also what is
the file Clock.vshost.exe; my application is Clock.exe.
Z.K.
'Clock.vshost.exe' (Managed): Loaded 'C:\Documents and
Settings\Super_Wizard\My Documents\Visual Studio
|
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#, J#, basically whatever you primarily worked with. I selected C#. It did give you an option to utilise all of the projects, but I silly neglected that.
Now, when I go to create a new project I'm only able to create C# projects. The problem is that...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |