|
Maximilien wrote: When the function is in the C++ file it produces a link error (LNK2019).
If I place the function in the H file, all goes well.
This is the expected behaviour: At the time of instantiating a DoSomething -version with double as template-parameter, the compiler needs the full definition of DoSomething .
So it has to be in the .h -file.
The easiest part is to just live with it.
And possibly have DoSomething call type-specific worker-functions from some cpp.
Failure is not an option - it's built right in.
|
|
|
|
|
When the function is in the C++ file it produces a link error (LNK2019).
You mean source file?
Anyway, you would better to show the class declaration. I guess it is in a header file. Thus the linker cannot bind the definition with a [proper] declaration. The simpliest way to solve the problem is moving the function definition into the header file [make it inline if you would like to define it outside the class declaration].
--
=====
Arman
|
|
|
|
|
I may not be following your problem correctly, but I placed the following code in a .cpp file and it compiled and linked fine:
template <class T>
class MyClass
{
public:
void DoSomething( int tag, T& value );
};
template <class T>
void MyClass<T>::DoSomething( int tag, T& value )
{
}
void main( void )
{
MyClass<double> myClass;
double d = 0.0;
myClass.DoSomething(2, d);
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
This reminds me of the sorts of errors I got on older compilers (when I was learning about templates) if the definition was not in the header. I don't know what the situation is with newer compilers as I always put the code in the header.
The reason was that it was necessary for the compiler to have the function definition when it encountered a specific instance of the templated function in order to create the code. To create the code for a templated function definition the compiler needs both the function definition and an instance that specifies what template parameters are required.
So for example, when the compiler encountered DoSomething<double> that would trigger it to create the actual 'double' version of the code. This would work if the definition was available to the compiler at the time; either in the header or in the actual source file that the 'double' version was used in. If it couldn't find the definition no object code was created and unless the code for DoSomething<double> was created elsewhere, a linker error would result.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
Just as a class isn't an object,
a template isn't a class/function.
The instance of the template is the class.
The compiler needs to know how to generate the class.
For this it needs access to the template definition.
When you put template code in the C++ file the compiler has nothing to compile because the template isn't a class (it's not compilable source code).
When you use the template to create an instance (a class/function i.e. MyClass::DoSomething<double>) the compiler needs to know, at that point, how to construct the class/function. Because you've put the code in a C++ file it can't see it when it compiles the module that wants to create/use the template instance.
... granted, this is how things are now, people have been talking for a while about getting compilers to 'pre-compile' templates (some how).
...cmk
Save the whales - collect the whole set
|
|
|
|
|
|
|
Is is possible to have some string resources using the same ID in more versions depending on defined constans (in visual studio 6.0)? Or use more than one resource file?
I can have multiple versions dialogs/icons/bitmaps, but I cannot find this option for strings.
Thank you!
rrrado
|
|
|
|
|
rrrado wrote: string resources using the same ID in more versions
What this means?
Are you trying to store string in different language while keeping the ID same.
It is possible to keep the ID same and have string in different language.
Afterwards you can retrive any string depending upon the language using the same ID.
|
|
|
|
|
It is not for different languages, but I've solved this.
Thank you.
rrrado
|
|
|
|
|
Hello All,
In our project client need to lock all HotKeys.I have tried
SetWindowHookEx(Wh_KeyBoard,KeyProc,...);
But it lock all keys except hotkeys
LPRESULT WINAPI CALLBACK KeyProc(int nCode,WPARAM wParam,LPARAM lParam)
{
......
}
So I have tried
#define _WIN32_WINNT 0x0400
#include <windows.h>
SetWindowHookEx(Wh_KeyBoard_LL,LowLevelKeyBoardProc,...);
LPRESULT WINAPI CALLBACK LowLevelKeyBoardProc(int nCode,WPARAM wParam,LPARAM lParam)
{
......
PKDLLHOOKSTRUCT p=(PKDLLHOOKSTRUCT)lParam;
or
KDLLHOOKSTRUCT *p=(KDLLHOOKSTRUCT *)lParam;
}
But it doent work WH_KEYBOARD_LL doesnt call the LowLevelinputProc
even dll also not working
I have installed vc6.0 and Platform SDK Servoce Pack 2
Plese give me any information that how I can Lock the Hotkeys
|
|
|
|
|
Are KeyProc() and LowLevelKeyBoardProc() in a DLL?
abhiakude wrote: ...WH_KEYBOARD_LL doesnt call the LowLevelinputProc
How are you verifying this?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes KeyProc and LowLevelKeyBoardProc are in dll
First I am Loading the dll using LoadLibrary
and call both procedures using SetWindowHook in My main application
but WH_KEYBOARD for KeyProc work propely but not for LowLevelKeyProc
So I have used WH_KEYBOARD_LL but it cant call the LowLevelKeyProc
For verifying this i am displaying one Messagebox in both procedures in the dll.
|
|
|
|
|
What does your call to SetWindowHookEx() look like?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Now I am successfully locked all hotkeys using SetWindowHookEx(WH_KEYBOARD_LL,...) but it does not lock Ctrl+Alt+Del key.Is there any solution to lock using SetWindowHook or any other method for it.
|
|
|
|
|
You'll need to provide your own GINA DLL, thus replacing Microsoft's (MSGINA.DLL).
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Is it possible to have reference to a reference varible.
Why?
KIRAN PINJARLA
|
|
|
|
|
It is possible to have reference to a reference variable. But reference to a variable and reference to the reference variable will point to the same location and they will have same value.
i.e.
int i = 5;
int& ii = i;
int* p = ⅈ
int* p1 = &i;
the p and p1 will have same value after executing the above code.
Manoj
Never Gives up
|
|
|
|
|
Aha, you are counting a reference and two pointers.. Generally speaking, pointers are also references
--
=====
Arman
|
|
|
|
|
I guess you mean "a reference refering to another reference refering to a variable". If so, impossible. A reference is initialized and never changes its referee; no assignment to change the referee later. So no way to initialize smth with a value that is being initialized [by other value] at the same time. Funny.
--
=====
Arman
|
|
|
|
|
kiran.pinjarla wrote: Is it possible to have reference to a reference varible.
Sure:
#include "stdafx.h"
#include "iostream"
int _tmain(int argc, _TCHAR* argv[])
{
int i = 5;
int& ri = i;
int& rri = ri;
std::cout << i << ri << rri << std::endl;
rri = 6;
std::cout << i << ri << rri << std::endl;
return system("pause");
}
kiran.pinjarla wrote: Why?
Hmm. To not make up a special case by not allowing it?
After all, an int& is supposed to be like an int in all respects. It is just another name for a variable.
Failure is not an option - it's built right in.
|
|
|
|
|
|
Hi,
Why dont you try to check value of the "kon" after the
IplImage* kon=mycam->capture(); //it would return a IplImage*
line. If every thing is fine the the value of kon should be not null.
Otherwise you need to check the capture function for creating the image successfully.
Manoj
Never Gives up
|
|
|
|
|
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.
|
|
|
|
|
I saw an interest thing on the C++/CLI forum,I saw some C++ questions on that fourm and some CLI questions on the C++ forum.
|
|
|
|