|
I would say:"Why don't you post it in the right place?", but you've already done so. Hence I say:"Good luck!".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi to All,
Could you please clear my following doubt.
I have 3 class with multilevel inheritance as follows,,...
class A
{
public:
A()
{
s();
}
virtual void s()
{
printf("\nIn A");
}
};
class B:public A
{
public:
};
class C:public B
{
public:
void s()
{
printf("\nIn C");
}
};
int main(int argc, char* argv[])
{
A *ptr = new C();
}
when i create an object of C,...by theory it should call always the method S of C....am I correct?...but when I called C from A's constructor Its calling S() of C....Why so?...Could anyone please explain me the reason and some points on it??
thanks in advance
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: but when I called C from A's constructor Its calling S() of C....
You mean it is calling s() of A, right ?
That's normal because when A is being constructed, it's virtual table is not create yet, which means that the call can't be redirected properly. So, the rule is simple: never call a virtual function from within a constructor.
Read this[^] for instance.
|
|
|
|
|
Not quite, Cedric - in A's constructor, the object has A's v-table. See the C++ 98 Standard, Section 12.7-3.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
When u create base class pointer as derived class using new, it first allocate memory for base class one by one, call their constructors, initialize their member variables , finally it call declared class constructor(here it is Class C). since fn s() is called in class A's Constructor, it invoke its own fn even though u declared it as virtual.
A *ptr = new C();
if you define like this ,
A *ptr = new C();
ptr->s();
Class C's fn of s() will be invoked!
hemmalatha.g
|
|
|
|
|
When constructing an object, base class constructors use that base classes virtual function table. So, when you call C's constructor, the first thing it does is call B's (implicitly defined) constructor, which call's A's constructor. Within A's constructor, only virtual functions defined in A can be called. Within B's constructor, only virtual functions defined in A or B can be called. Within C's constructor, virtual functions defined in A, B or C could be called.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Kindly let me know, how to use endorsement option in the scanner using twain
|
|
|
|
|
This is the C++ forum.
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
I use twain.h in vc++ application for scanner operation. twain.h file contains n number of capabilities (like CAP_DUPLEXENABLED,ICAP_XRESOLUTION,ICAP_AUTOMATICROTATE etc) which are supported by scanner. kindly help me how to use CAP_ENDORSER and TWEI_ENDORSEDTEXT capabilities to do endorsement in the scanner.
sujtha
modified on Wednesday, December 9, 2009 5:13 AM
|
|
|
|
|
I have this code that loads a DIB bitmap from a file and passes it to SetDIBitsToDevice.
This code works:
FILE* f = fopen(".\\bitmap1.bmp", "rb");
vector<BYTE> buffer;
buffer.resize(_filelength(f->_file));
fread(&buffer[0], buffer.size(), 1, f);
BITMAPINFO* bminfo = (BITMAPINFO*) &buffer[14];
BITMAPFILEHEADER* bmh = (BITMAPFILEHEADER*) &buffer[0];
LPVOID bits = &buffer[bmh->bfOffBits];
SetDIBitsToDevice(
pDC->GetSafeHdc(),
0,
0,
bminfo->bmiHeader.biWidth,
bminfo->bmiHeader.biHeight,
0,
0,
0,
bminfo->bmiHeader.biHeight,
bits,
bminfo,
DIB_RGB_COLORS
);
But this doesn't. The only differences are in the source origins and width/height/number of scanlines. I'm trying to pass a smaller rectangle that starts at (100,100) and has the same lower-right corner (hence smaller width/height).
FILE* f = fopen(".\\bitmap1.bmp", "rb");
vector<BYTE> buffer;
buffer.resize(_filelength(f->_file));
fread(&buffer[0], buffer.size(), 1, f);
BITMAPINFO* bminfo = (BITMAPINFO*) &buffer[14];
BITMAPFILEHEADER* bmh = (BITMAPFILEHEADER*) &buffer[0];
LPVOID bits = &buffer[bmh->bfOffBits];
SetDIBitsToDevice(
pDC->GetSafeHdc(),
0,
0,
bminfo->bmiHeader.biWidth-100,
bminfo->bmiHeader.biHeight-100,
100,
100,
0,
bminfo->bmiHeader.biHeight-100,
bits,
bminfo,
DIB_RGB_COLORS
);
What can be the problem with the second code?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
are you sure SetDIBitsToDevice lets you draw sub-sections of a DIB ?
|
|
|
|
|
I never have used SetDIBitsToDevice() myself. I would suggest you to use Stretchblt(), it's almost the same. I'm sure that one does the job...
My experience is that problems with these functions mostly are caused by:
- wrong coordinate system (try negative values)
- pending clipping areas
So if you try Stretchblt() and it doesn't work either you know its not in the coordinates..
And, as someone on CP a few days before suggested, there seems to be a 'DCviewer' somewhere on CP.
Good luck
Rozis
|
|
|
|
|
Hi,
I am writing a small app to connect 2 computers. When i test the server side right from my computer, it 's ok. But because i am using a shared network with a router, my friends cannot connect to my computer by using my IP (because it is a local ip). Can anyone suggest a way to overcome this problem, please?
|
|
|
|
|
You may configure your router for NAT [^], [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
so, that 's means i have to configure something "manually". Is there any solution by using code? I just wonder how p2p apps can work when 2 comps connected directly to each other and one comp is under a shared network
|
|
|
|
|
bubuzzz wrote: I just wonder how p2p apps can work when 2 comps connected directly to each other and one comp is under a shared network
When one of the two peer-to-peer appliacations is inside a private network, you've to configure (manually) the router for NAT .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
bubuzzz wrote: so, that 's means i have to configure something "manually". Is there any solution by using code? I just wonder how p2p apps can work when 2 comps connected directly to each other and one comp is under a shared network OMG
As long as one of the two peers is not firewalled (incoming connections are not blocked), they can make a connection. If both are in a local network without port forwarding it gets much more trickier, but there are still possibilities (as Skype shows).
/M
|
|
|
|
|
Port forwarding is not possible (see router configuration)?
|
|
|
|
|
yup. That is what i am trying these day. Thanks all for replying me
|
|
|
|
|
How do i generate tables in WORD through code? i am creating an application where i have to create tables depending on the input given. for example, if there are 10 objects there should be 10 rows and each row should have an object.
i was trying some examples in CP. couldnt find any.. if somebody can help me it would be great
|
|
|
|
|
There are actually some goo examples about office automation here at CP [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi Members
I am try to show Message when copy file or folder from windows explorer.Is it possible?
|
|
|
|
|
What do you mean?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
|
You want to show the copy operation progress while it is being performed? Take a look at CopyFileEx[^] function, especially the third parameter.
“Follow your bliss.” – Joseph Campbell
|
|
|
|