|
Hi. This is a continuation of the ? before. I just can't seem to compile the program.
I had a program with CClass and CBaseClass classes DONE without Template and it works fine. Now I changed things to:
template<class x=""> CBaseClass
{
...
}
Outside the template the functions are in..
template<class x=""> void CBaseClass<x>::Function()
{
...
}
I know the base baseclass declaration is OK
AND
template<class x=""> CClass: public CBaseClass<x>
{
//I tried several syntax for the constructor and other fuunctions
CClass();
virtual ~CClass();
OR
CClass():CBaseClass<x>();
virtual ~CClass():CBaseClass<x>();
void Function():CClass<x>::Function()
//Both don't work
}
Outside the template the functions are in..
template<class x=""> CClass<x>::CClass()
{
}
...
Now because everything worked before, and I only added the syntax for the template, I know that it must be the syntax or something.
The compiler error is:
error LNK2001: unresolved external symbol ...
What I really need is exactly what the syntax needs to be. I can't find this anywhere at the moment. What I changed seemed very straight forward.
Appreciate any help to clearing this syntax up. Thanks!!
|
|
|
|
|
Please repost and check the Display this message as-is (no HTML) box so your template params show up properly.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
OK. This is the second try.
I had a program with CClass and CBaseClass classes DONE without Template and it works fine. Now I changed things to:
template<class X> CBaseClass
{
...
}
Outside the template the functions are in..
template<class X> void CBaseClass<X>::Function()
{
...
}
I know the base baseclass declaration is OK
AND
template<class X> CClass: public CBaseClass<X>
{
//I tried several syntax for the constructor and other fuunctions
CClass();
virtual ~CClass();
OR
CClass():CBaseClass<X>();
virtual ~CClass():CBaseClass<X>();
void Function():CClass::Function<X>()
//Both don't work
}
Outside the template the functions are in..
template<class X> CClass<X>::CClass()
{
}
...
Now because everything worked before, and I only added the syntax for the template, I know that it must be the syntax or something.
The compiler error is:
error LNK2001: unresolved external symbol ...
What I really need is exactly what the syntax needs to be. I can't find this anywhere at the moment. What I changed seemed very straight forward.
|
|
|
|
|
template <class X> class CBaseClass
{
};
template <class X> class CClass : public CBaseClass<X>
{
CClass();
virtual ~CClass();
void Function();
};
template <class X>
CClass<X>::CClass() : CBaseClass<X>()
{ }
template <class X>
CClass<X>::~CClass()
{ }
template <class X>
void CClass<X>::Function()
{ }
|
|
|
|
|
Hi Michael.
Thanks for the patience and help thus far.
From what I can see, only the template declaration and the Constructor for the derived class has different syntax. The others look normal template syntax. I tried this but am getting:
error LNK2001: unresolved external symbol "public: virtual __thiscall CTCRSSRecoilCoilReport<class CCircBufferT<float,struct _DATA_STRUCTURE_> >::~CTCRSSRecoilCoilReport<class CCircBufferT<float,struct _DATA_STRUCTURE_> >(void)" (?
?1?$CTCRSSRecoilCoilReport@V?$CCircBufferT@MU_DATA_STRUCTURE_@@@@@@UAE@XZ)
error LNK2001: unresolved external symbol "public: virtual void __thiscall CTCRSSRecoilCoilReport<class CCircBufferT<float,struct _DATA_STRUCTURE_> >::EndCoilReport(class CString,struct _RECOILING_COIL_REPORT_HOLDER_ *)" (?EndCoilR
eport@?$CTCRSSRecoilCoilReport@V?$CCircBufferT@MU_DATA_STRUCTURE_@@@@@@UAEXVCString@@PAU_RECOILING_COIL_REPORT_HOLDER_@@@Z)
error LNK2001: unresolved external symbol "public: __thiscall CTCRSSRecoilCoilReport<class CCircBufferT<float,struct _DATA_STRUCTURE_> >::CTCRSSRecoilCoilReport<class CCircBufferT<float,struct _DATA_STRUCTURE_> >(void)" (??0?$CTCRS
SRecoilCoilReport@V?$CCircBufferT@MU_DATA_STRUCTURE_@@@@@@QAE@XZ)
...
from the locations where I am calling the classes. I am not sue what this means unless the way you call it is different then normal template calling (Which is different only in declaration).
I am not sure what the Link 2001 error means. I know that the program did work right before. It seems like the program is getting errors from just calling the classes so I must not be declaring things right somewhere.
Thanks.
|
|
|
|
|
|
Hi Micheal. Thanks. I will try this.
|
|
|
|
|
Hi Michael.
I tried this. I ended PUT ALL the functions insides the template itself all in the header file. But it is still the same Link 2001 unresolved external symbol error. I can't understand it. I never had to put all the functions in the template in the heade file if it is not derived from it. It works fine.
I am really confused now as to what is actually the problem. It must be syntax. Right now I just want to change it to this class and its derived class to a template. I am not actually using the <class X> part yet meaning it should still work as before without the template declarations.
Any other ideas? Appreciate your help through this
|
|
|
|
|
I include a gif resource into my project but every time I build it the gif becomes 0 kb and when I try to view it in windows it says no preview available. I am using MS VC++ 6.0 w/ service pack 5. Anyone else with this problem?
|
|
|
|
|
http://www.wintellect.com/forum/topic.asp?TOPIC_ID=1132
so im creating this System Wide Keyboard Hooking Function, and i thought it would catch everything , but this group is having a discussion about it, and one says a SWKH will not catch a Ctrl-Alt-Delete, is that true??
todo....
:: insert inpirational text here ::
|
|
|
|
|
Of course not. The whole point of C+A+D is that it's secure - when you press it, only the OS responds to it.
--Mike--
I'm bored... Episode I bored.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Believe me:
if you want to catch Ctrl+Alt+Del you must do one of this things:
1. Create a Gina DLL.
2. Get a Gina DLL from somewhere.
the reason is clear:
In order to be secure its forbidden to get acces directly from an app to the Login part of the OS.
You've got to do it via a GINA that must be installed in the OS copying it somewhere and giving it's right path in the registry.
Take a look at the MSDN in order to find out more.
hope this helps...
|
|
|
|
|
|
|
Hey guys,
I'm having some trouble with a std::map object I'm trying to use. Can any STL guys out there see something I'm doing wrong in my code. I've been debugging this for a couple hours now, stepping through STL code (which isn't fun!).
All I'm trying to do is associate a structure with a string. So, I insert a value_type with a string and a structure, then I try to look up the exact same string, and I get an invalid iterator. One wierd thing, is that it works perfectly for the first item I insert. Looking at the guts of the tree, I can see that the second object is there, it just checks the wrong side of the tree when it goes to look it up .
typedef basic_string<TCHAR> CTCharString;
struct CTCharStringLess : public binary_function<CTCharString, CTCharString, bool>
{
bool operator()(const CTCharString& x, const CTCharString& y) const
{
return _tcscmp( x.c_str(), y.c_str() );
}
};
typedef struct tagFoo
{
long Bar;
}Foo;
typedef map<CTCharString,Foo,CTCharStringLess> CStdMapStringToStruct;
CStdMapStringToStruct MyMap;
Foo stMyStruct;
MyMap.insert( CStdMapStringToStruct::value_type( _T("dummy_item", stMyStruct ) );
CStdMapStringToStruct::iterator oIter = MyMap.find( _T("dummy_item") );
MyMap.insert( CStdMapStringToStruct::value_type( _T("dummy_item_2"), stMyStruct ) );
oIter = MyMap.find( _T("dummy_item_2") );
Thanks,
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
i suspect :
return _tcscmp( x.c_str(), y.c_str() );
should be
return _tcscmp( x.c_str(), y.c_str() ) < 0;
|
|
|
|
|
Wow, do I feel like a dummy. Of course, your suggestion works perfectly.
Thanks!
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
Hey all, me again
i started a new thread because (thanks to all the cpians) i figured out the initial parts of the app i needed, and now its onto the next issue I have
to keep people from exiting my app , i need to disable all the ctrl-alt-delete , altf4 stuff, and the ::pretranslatemessage stuff is not quite robust enough for me
so apparently i need to create a system wide keyboard hook.....
i have no idea how to start.
please help
josh
todo....
:: insert inpirational text here ::
|
|
|
|
|
System Wide KH only can be in a DLL so...
STEPS:
1. You must create a DLL.
2. Declare a static callback function:
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam);
3. Create a f(x) that you'll export in order to start/stop that hook depending on a boolean parameter:
Setting the hook:hHookTeclat = SetWindowsHookEx(WH_KEYBOARD_LL, HookTeclatLL, hInstDLLSCT, NULL);
Unhooking:
if(hHookTeclat != NULL)
{
UnhookWindowsHookEx(hHookTeclat);
return true;
}
4. in the static callback f(x)...
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam)
{
if (nCode == HC_ACTION)
{
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
{
LPKBDLLHOOKSTRUCT p = (LPKBDLLHOOKSTRUCT)lParam;
bool bEliminarPressioTecla = false;
bEliminarPressioTecla = ((p->vkCode == VK_RWIN) ||
(p->vkCode == VK_LWIN) ||
(p->vkCode == VK_ESCAPE) ||
(p->vkCode == VK_F1) ||
(p->vkCode == VK_F2) ||
(p->vkCode == VK_F3) ||
(p->vkCode == VK_F4) ||
(p->vkCode == VK_F5) ||
(p->vkCode == VK_F6) ||
(p->vkCode == VK_F7) ||
(p->vkCode == VK_F8) ||
(p->vkCode == VK_F9) ||
(p->vkCode == VK_F10) ||
(p->vkCode == VK_F11) ||
(p->vkCode == VK_F12) ||
(p->vkCode == VK_CANCEL) ||
(p->vkCode == VK_RBUTTON) ||
(p->vkCode == VK_PAUSE) ||
(p->vkCode == VK_SNAPSHOT) ||
(p->vkCode == VK_APPS) ||
(p->vkCode == VK_SCROLL));
if (!bEliminarPressioTecla)
{
if ((p->flags & LLKHF_ALTDOWN) != 0)
{
bEliminarPressioTecla = (p->vkCode == VK_TAB);
}
if ((p->flags & MOD_WIN) != 0)
{
bEliminarPressioTecla = true;
}
}
if (bEliminarPressioTecla)
{
return 1; IMPORTANT! in order to avoid that keystroke to be used...
}
break;
}
}
}
return CallNextHookEx(hHookTeclat, nCode, wParam, lParam);
}
I didn't wanted to format all that code... copy it and examine it outside the web page...
Hope this helps...
I'll go to sleep...
|
|
|
|
|
i just left work so i cannot check the code out til i get home, but it looks like a pretty straight forward guide Thanks!
todo....
:: insert inpirational text here ::
|
|
|
|
|
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam)
{
if (nCode == HC_ACTION)
{
switch (wParam)
{
case WM_KEYDOWN:
case WM_SYSKEYDOWN:
case WM_KEYUP:
case WM_SYSKEYUP:
{
LPKBDLLHOOKSTRUCT p = (LPKBDLLHOOKSTRUCT)lParam;
bool bEliminarPressioTecla = false;
// Paquet de tecles independents (hi hagi o no apretat ALT/Ctrl... s'eliminen de la cua de pressions de tecles).
bEliminarPressioTecla = ((p->vkCode == VK_RWIN) ||
(p->vkCode == VK_LWIN) ||
(p->vkCode == VK_ESCAPE) ||
(p->vkCode == VK_F1) ||
(p->vkCode == VK_F2) ||
(p->vkCode == VK_F3) ||
(p->vkCode == VK_F4) ||
(p->vkCode == VK_F5) ||
(p->vkCode == VK_F6) ||
(p->vkCode == VK_F7) ||
(p->vkCode == VK_F8) ||
(p->vkCode == VK_F9) ||
(p->vkCode == VK_F10) ||
(p->vkCode == VK_F11) ||
(p->vkCode == VK_F12) ||
(p->vkCode == VK_CANCEL) ||
(p->vkCode == VK_RBUTTON) ||
(p->vkCode == VK_PAUSE) ||
(p->vkCode == VK_SNAPSHOT) ||
(p->vkCode == VK_APPS) ||
(p->vkCode == VK_SCROLL));
// En cas que no s'hagi eliminat la tecla fins ara...
if (!bEliminarPressioTecla)
{
// Paquet de tecles amb combinació amb ALT.
if ((p->flags & LLKHF_ALTDOWN) != 0)
{
bEliminarPressioTecla = (p->vkCode == VK_TAB);
}
if ((p->flags & MOD_WIN) != 0)
{
bEliminarPressioTecla = true;
}
}
if (bEliminarPressioTecla)
{
return 1; IMPORTANT! in order to avoid that keystroke to be used...
}
break;
}
}
}
return CallNextHookEx(hHookTeclat, nCode, wParam, lParam);
}
Deleting intermediate files and output files for project 'swkh - Win32 Debug'.
--------------------Configuration: swkh - Win32 Debug--------------------
Compiling...
swkh.cpp
c:\windows\desktop\visualstudio6\myprojects\swkh\swkh.cpp(1) : error C2146: syntax error : missing ';' before identifier 'CALLBACK'
c:\windows\desktop\visualstudio6\myprojects\swkh\swkh.cpp(1) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
swkh.dll - 2 error(s), 0 warning(s)
todo....
:: insert inpirational text here ::
|
|
|
|
|
I've ommitted one thing...
you've to change those lines in stdafx.h (comment the first one as in the sample and add the second one...):
#define _WIN32_WINNT 0x0400
|
|
|
|
|
Thank You Joan Murt, youve been extremely helpful for me.
if (bEliminarPressioTecla)
{
return 1; IMPORTANT! in order to avoid that keystroke to be used...
}
break;
}
}
I also forgot to comment that part
Im going to try to build this .dll later today, i got a few other duties to perform first ill let you know how it goes....
todo....
:: insert inpirational text here ::
|
|
|
|
|
Hello,
I have the name of a variable, let's call it "iCounter", is there any way to set a value to a var when I got only its name?
Sample of what I means:
CString csNameOfVar = "iCounter";
GetTheAdressOfAVarWiththisName(csNameOfvar) = Value_that_I_Must_set;
Does a function that acts as "GetTheAdressOfAVarWiththisName" exists?
thank you in advance.
|
|
|
|
|
That would be fun, but I don't think so... C++ is not symbolic!
but,
One way of doing it, would be to add your variable into a map with the name of the variable as the key; but maybe not!?!?!
Max,
|
|
|
|