|
In MFC the easiest way is to use __argv[0]
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
//object.h
#ifndef _OBJECT_H
#define _OBJECT_H
template< class A >
class Object
{
public:
Object(){}
virtual ~Object(){}
template< class B >
class Item
{
public:
Item(){}
virtual ~Item(){}
void Item_Func(B& b){}
};
template< class B >
void Func1(Item<B>& item)
{
return;
}
template< class B >
void Func2(Item<B>& item)
{
return;
}
};
#endif
//main.cxx
#include "object.h"
Object<int> object;
void foo()
{
Object<int>::Item<char> item2;
object.Func2( item2 );
}
int main()
{
Object<int>::Item<int> item1;
object.Func1( item1 );
return 0;
}
//Error:
g++ -c -g -o main.o main.cxx
main.cxx: In function `int main()':
main.cxx:16: no matching function for call to `Object<int>::Func1 (Object<int>::Item<int> &)'
make: *** [main.o] Error 1
I'm amumu, and you?
|
|
|
|
|
If I had to guess, I would say that it is because you have declared a class A template parameter in your object class, and class B in the Func1 function. This code compiles fine in VC++ 6.0.
Also, I do not think that there are many people on this forum with experience in g++.
|
|
|
|
|
If I comment the foo(), that's no problem.
I am confused about it, may be it is the bug of g++?
I'm amumu, and you?
|
|
|
|
|
Hi,
I know that if there are several threads share a common array, i need criticalSection to protect to prevent all threads trying to WRITE to this array at the same time.
However, I just wonder if criticalSection is required to prevent all threads trying to just READ the info from this array at the same time.
Thanks!
|
|
|
|
|
It is not required, there is not a problem if everyone is just reading. However if you have some threads reading and other writing then you must protect yourself as well
Best regards,
Alexandru Savescu
|
|
|
|
|
Yes, because if you don't then you run the risk of reading while someone is writing and thus the data might be suspect.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
#include <iostream.h>
class a
{
public:
a()
{
cout<<"a::a"<<endl;
}
="" ~a()
="" {
="" cout<<"a::~a"<<endl;
="" }
};
class="" b:public="" a
{
private:
="" char*="" ptch;
public:
="" b()
="" cout<<"b::b"<<endl;
="" ptch="new" char[100];
="" ~b()
="" cout<<"b::~b"<<endl;
="" delete="" ptch;
="" }
};
int="" main()
{
="" b*="" ptb="new" b;
="" a*="" pta="ptb;
" pta;
=""
="" return="" 0;
}
and="" how="" about="" this="" one?
#include="" <iostream.h="">
class a
{
public:
a()
{
cout<<"a::a"<
|
|
|
|
|
The first one causes a memory leak because the destructor for class b does not get called. If you make the destructor in class b virtual, then the destructor will get called, and there will be no memory leak.
The second one does not cause a memory leak, because there is no dynamic memory allocation internal to either class.
|
|
|
|
|
I see, Thank you very much!
I'm amumu, and you?
|
|
|
|
|
Yes you need to make the class b destructor virture. The destructor for class b is wrong as well. To avoid memory leak, the class b destructor should be:
virture ~b
{
....
delete []ptch;
}
|
|
|
|
|
'virture'? Is it from Java?
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
You have to make a's destructor virtual. Once that is done, B's destructor will also by definition be virtual.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi
does anyone use the install-shield app which comes with VC 6.0?
Ive been messing about with it today and have a question or two
Bryce
|
|
|
|
|
Yep, what are your questions?
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
hi,
I have a application that traps the keystrokes using hooks.I want send these trapped keystrokes to another application.
Thanks in advance
|
|
|
|
|
Use SendInput (not available on Win95) or keybd_event.
Tomasz Sowinski -- http://www.shooltz.com ** If you're going to rape, pillage and burn, be sure to do things in that order. **
|
|
|
|
|
how do you direct the keyboard event generated by keybd_event to particular window.
|
|
|
|
|
hi,
I have a application that traps the keystrokes using hooks.I want send these trapped keystrokes to another application.
Thanks in advance
|
|
|
|
|
What's the easiest way for an app to know when a machine (say, a laptop) has come out of hibernation? In CE there is the WM_HIBERNATE message but I can't seem to find a win32 equivalent.
cheers,
Chris Maunder
|
|
|
|
|
WM_POWERBROADCAST?
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I'll give it a shot - thanks Derek!
cheers,
Chris Maunder
|
|
|
|
|
Hi,
Can anyone please give me an example of the function:
QueryPerformanceCounter()??
What I know is that it is related to "high-resolution performance...". But, I don't really know how to use it.
Thank you!
|
|
|
|
|
|
Thank you! I've actually checked that out already.
And, I've found an even simpler program about that.
|
|
|
|