|
Computafreak wrote: In what way am I heading towards trouble?
The scope of that question is far to large to discuss in a forum which is why I referred you to other sources. However a quick couple of points I will provide are; 1) your notion of calling the base class method after the Bar method. Notice in my posted example the base class is called first. That is because in your posted code the Bar method frees the memory.
void DoSomething(void *p)
{
if(p)
free(p);
}
Calling the Foo method after that would result in the Foo method having an invalid pointer.
2) Also using void pointers is NOT Best Practice. Strongly Typed code is preferable.
Anyway all of these types of problems are covered in materials such as the ones I pointed you at. How do you think I know about them? I didn't invent anything you know, I learned from others. 
|
|
|
|
|
The second problem is simply a problem with my example. I was in rather a rush, so apologies for causing the misunderstanding. I hadn't thought about the first problem though. You're right; the base class' method should be called first. But is there any way to make this call implicit?
|
|
|
|
|
Computafreak wrote: But is there any way to make this call implicit?
Not sure how to respond to that. If you have to do something to make it happen then it can't be implicit can it? If they made that implicit, then you would have to do something to eliminate the base being called. It seems the current way is more obvious therefore easier to understand, yes?
|
|
|
|
|
What I mean is this. Normally, when the derived class' method is called, the base class' method is not. What I'm looking for is how to make the base' class method be called, and then the derived class' method
Example: I call Bar->DoSomething((void *)0x12345), the parameters are pushed onto the thread's stack, and Bar::DoSomething is invoked. I want the parameters to be pushed, Foo::DoSomething to be called (the base class) and then Bar::DoSomething to be called (the derived class) automatically
If it helps, a little background. I have a Stream base class. It has a LinkedStream property, which refers to a Stream pointer. When I call Stream::Write, I want to call LinkedStream->Write beforehand, then pass the arguments to the derived class' write method
|
|
|
|
|
Computafreak wrote: I want the parameters to be pushed, Foo::DoSomething to be called (the base class) and then Bar::DoSomething to be called (the derived class) automatically
Then write your own language and compiler that will do that I guess. I terms of C++ it's like you are saying you want up to be down. That's just to bad for you because it isn't, period.
However I would also point out that it seems you are making a big deal out of nothing. In your background explanation with streams, if your derived class just calls the base first it results in the runtime behavior you describe.
|
|
|
|
|
I see now. Thanks for the explanation. I'm definitely not going to be writing my own compiler, but I see how my request wasn't in the best of understanding. You've been very helpful; thanks again
|
|
|
|
|
Hi,
I've got a few extensions I need to add to the registry so when the user is exploring via windows explorer they will see a default icon I've created for the extensions. I've already created a script to register the 'display description' (ie: '.htm' file extensions are described with 'HTML Document'). That, I have working.
What keys do I need to create in order for an icon to be displayed for the file. (By default, the 'Unknown Document' is shown.) I want to display my own icon. All the sites I've explored during my research only mention how to change existing registry entries.
I need a .reg file because the app is going to be deployed.
Will I need to create a CLSID or use one from the App that has been created? I'm thinking I'm going to need 2 or 3 registry entries in order to get this to work but I don't know where to start.
Anyone help? Thanks! 
|
|
|
|
|
Like2Byte wrote: but I don't know where to start.
Like2Byte wrote: Anyone help?
Sure I always enjoy helping the Google impaired. Knock yourself out[^]
|
|
|
|
|
I get the previously said error when i build in the following combination
Pockect PC 2003 ;
Win32 (Win CE Emulator debug or Release) ;
Pocket PC 2003 device;
but when i chage the configuration to the following
Pockect PC 2003 ;
Win32 (Win CE Arm debug or Release) ;
Pocket PC 2003 device;
I get the following error :
winscard.lib(WINSCARD.dll) : fatal error LNK1112: module machine type 'THUMB' conflicts with target machine type 'ARM'
Any clue why this happens ?
Thanks !
|
|
|
|
|
kapardhi wrote: module machine type 'THUMB' conflicts with target machine type 'ARM'
Does this[^] help? (Search for THUMB in the linked page).
Also - this message maybe gives a clue as to why your original error occurs - how can you talk to smartcards in an emulator - it has no real hardware?!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
this i used to access information from registry, but the problem is that it prints only first character of the string , instead of whole.
void GetProxyServerInfo()
{
try
{
HKEY hKey;
if (RegOpenKeyEx(HKEY_CURRENT_USER, TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"), 0L, KEY_ALL_ACCESS, &hKey)!=ERROR_SUCCESS)
printf("nError opening the desired subkey (doesn't exist?).n");
else
{
DWORD dwType = REG_SZ;
char buf[255] = {0};
DWORD dwBufSize = 255;
if( RegQueryValueEx(hKey,TEXT("ProxyServer"),0, &dwType, (LPBYTE)&buf, &dwBufSize) == ERROR_SUCCESS)
{
//here it prints only single character, not the whole string
cout<< buf;
}
else
cout << "can not query for key value\n";
RegCloseKey(hKey);
}
}
catch(char *error)
{
throw error;
}
}
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
Hello Mogaambo,
Is unicode defined? then use wcout instead of cout .
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
i used wcout still the problem exists.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
i used wchar_t this and problem solved.
“You will never be a leader unless you first learn to follow and be led.”
–Tiorio
"Coming together is a beginning, staying together is progress, and working together is success." Henry Ford
|
|
|
|
|
It would be better to use TCHAR, so that you are independant of the unicode settings. Take a look at this article[^] for extended information.
|
|
|
|
|
I have set view matrix like this:
D3DXVECTOR3 vEyePt( 0.0f, 2.0f, -3.0f );
D3DXVECTOR3 vLookatPt( 0.0f, 0.9f, 0.0f );
D3DXVECTOR3 vUpVec( 0.0f, 1.0f, 0.0f );
D3DXMATRIXA16 matView;
D3DXMatrixLookAtLH( &matView, &vEyePt, &vLookatPt, &vUpVec );
g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
I want to retrive the eye, lookat and up vector for a purpose to change the vector.I get the eye point like this way:
D3DXMATRIXA16 m;
g_pd3dDevice->GetTransform(D3DTS_VIEW, &m);
D3DXMATRIX invm;
D3DXMatrixInverse(&invm,NULL,&m);
D3DXVECTOR3 v;
D3DXVECTOR3 cameraLoc;
v.x = 0;
v.y = 0;
v.z = 0;
D3DXVec3TransformCoord(&cameraLoc,&v,&invm);
D3DXVec3TransformCoord API get the eye vector = (0.0f, 2.0f, -3.0f ).Does anybody knows how the get the other lookat and up vector?
Thanks in advance....
Kallol
|
|
|
|
|
Hi,
I know Assert function can raise a break in Debug mode. It helps a lot.
but when it is in Release mode,the Compile ignore Aseert function. then how can I know it meets a error?
for example:
int open_file(char * filename)
{
FILE *fp;
fp=fopen(filename,"wr"); //p1
assert(fp!=NULL); //p2
//do something
//p3
}
in Debug mode:
when p1 fail, fp will be NULL and the assert will raise a break,then it exit.
in Release mode:
the Compile ignore the assert function, what should I do if fopen failed?
if it will go on running statements after p3 ?
to avoid this happend, should I have to replace all the assert statements in Release mode?
thank you.
|
|
|
|
|
You are not using the assert properly. This function should be used only to test the code. An assert should never be reached in a released product. Assert is used to detect errors in your code, not detect a file which is missing. In your case, if the file doesn't not exist you should handle the error in a better way. For instance your function could return an error code or throw an exception which has to be handled at a higher level.
|
|
|
|
|
|
China_Kevin wrote: 强烈同意楼上~~~~~
Uh, what ??
|
|
|
|
|
I am Chinese,HOHO, 强烈同意楼上~~~~~ just means I agree with you very much...
|
|
|
|
|
your name "Cedric" why your "C" is brighter than my name "China_Kevin" "C"
|
|
|
|
|
Because he is an MVP.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
I hereby bestow on you a "brighter" name:
China_Kevin
Carry it with honor.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|