473,387 Members | 1,687 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.

Some questions about optimization,help me.

wqe
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?

Mar 12 '07 #1
6 1890
wqe wrote:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?
If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john
Mar 12 '07 #2
wqe
ok,John

telnet2008

On 3ÔÂ12ÈÕ, ÏÂÎç2ʱ54·Ö, John Harrison <john_androni...@hotmail.comwrote:
wqe wrote:
Hi,everyone:
the questionly code:
#include <iostream>
using namespace std;
class test
{
int x;
void func()
{
};
void func1()
{
};
public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};
int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}
if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".
There is an answer, the f() was defined in the class test.
but if I define test::f() out of the class test, like this:
class test
{
int x;
void func()
{
};
void func1()
{
};
public:
void f();
};
void test::f()
{
printf("%x\n",&x);
};
I also cannot find the location of "f()" in the output disassemble
file,why?
if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.
why?

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.

john- Òþ²Ø±»ÒýÓÃÎÄ×Ö -

- ÏÔʾÒýÓõÄÎÄ×Ö -

Mar 12 '07 #3
John Harrison wrote:
wqe wrote:
>>why?

If you want to know how the Visual Studio 2003 compiler works then you
should ask on a Microsoft group. Try one of the groups in
microsoft.public.vc.*

This group is for C++ language questions only.
Do you have to quote the entire post in order to redirect it?

--
Ian Collins.
Mar 12 '07 #4
wqe wrote:
Hi,everyone:

the questionly code:
#include <iostream>

using namespace std;
class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f()
{
printf("%x\n",&x);
printf("%x\n",&test::func );
printf("%x\n",&test::func1 );
};
};

int main()
{
test a;
a.f();
test * ap = &a;
void(test::*pmem)(void)=&test::f;
printf("%x\n",pmem );
test b;
b.f();
test * bp = &b;
return 0;
}


if delete this 3 statements: test * ap = &a;
void(test::*pmem)
(void)=&test::f;
printf("%x\n",pmem );
test b;
in vs2003-release,in export map file and disassemble output file,
cannot
find the location of "f()".

There is an answer, the f() was defined in the class test.

but if I define test::f() out of the class test, like this:

class test
{
int x;

void func()
{

};
void func1()
{

};

public:
void f();
};

void test::f()
{
printf("%x\n",&x);
};

I also cannot find the location of "f()" in the output disassemble
file,why?

if I close the optimiztion(/0d)setting of this win32 console
program(vs2003 release), I
can find f() in the disassemble output file.
but if I open /0d,even add some parameters,returned something, and
defined
a local variable,I also cannot find f() in the disassemble output
file.

why?
Hello there, your question is irrelevant in this group. But in essence,
your compiler is free to optimize away test::f under certain conditions
and inline the function directly at the call site. As long your final
executable works as expected, you shouldn't worry about these details.
Mar 12 '07 #5
please tell me how to reply the topic

Mar 13 '07 #6
wufeng wrote:
please tell me how to reply the topic
But you did! If you want to quote, you need to learn to use
your news-reading software. And since it's one of those basic
tasks (and depends on the software you're using), please
consult with the 'alt.newbies' or the 'alt.usenet.newbies' or
the 'alt.usenet.software' forums. Good luck!
Mar 13 '07 #7

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

Similar topics

25
by: Brian Patterson | last post by:
I have noticed in the book of words that hasattr works by calling getattr and raising an exception if no such attribute exists. If I need the value in any case, am I better off using getattr...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
50
by: Jatinder | last post by:
I 'm a professional looking for the job.In interview these questions were asked with some others which I answered.But some of them left unanswered.Plz help. Here are some questions on C/C++, OS...
15
by: Marc Thrun | last post by:
Hello, I've got a few questions: 1) Given the two structs struct A { int x; }; and
1
by: Jobs | last post by:
What is application object ? Application object can used in situation where we want data to be shared across users globally. What's the difference between Cache object and application object...
0
by: Jobs | last post by:
All answers to the below interview questions are at http://www.geocities.com/dotnetinterviews/ or you can download the complete answer zip file from...
39
by: Digital Puer | last post by:
I'm not the world's greatest C++ programmer, so I had a hard time with these. Some help would be appreciated. 1. Comment on the declaration of function Bar() below: class Foo { static int...
2
by: freepdfforjobs | last post by:
Full eBook with 4000 C#, JAVA,.NET and SQL Server Interview questions http://www.questpond.com/SampleInterviewQuestionBook.zip Download the JAVA , .NET and SQL Server interview sheet and rate...
6
by: Patrick Sullivan | last post by:
Hello. I will be using some large data sets ("points" from 2 to 12 variables) and would like to use one class for each point rather than a list or dictionary. I imagine this is terribly...
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
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
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.