|
I have template class where the declarations are in a header file Check.h and the definition is give in a .cpp file Check.cpp.
I am using another file Test.cpp containing the main function to create an instance of the class. The problem is that when I include Check.cpp in Test.cpp it works fine. However, on including Check.h instead of Check.cpp in Test.cpp, I am getting this error
error LNK2001: unresolved external symbol "public: void __thiscall CTest<int>::CheckMethod(void)" (?CheckMethod@?$CTest@H@@QAEXXZ)
What can be the reason for this?
|
|
|
|
|
This is a very common (and interesting) problem with how template instantiation is performed. The subject is deeper than I'm going to explain, but this can serve as a starter.
The template definition (Check.cpp in your case) can be considered as a "code skeleton" that the compiler uses to generate the actual code when needed. The process of generating actual code from the template definition is called instantiation:
template <class T> class foo
{
...
};
...
foo<int> a;
foo<string> b; The point of instantiation (POI) does not occur at the definition, but when the template is first used. Except in cases I will not go into, the definition of the template must be visible from the POI.
So, in your second situation the POI in Test.cpp does not see where the definition of the template is, while compiling Check.cpp alone does not produce any code at all (no instantiation inside Check.cpp .) You got it?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks Joaquin, I got it. Where can I find some material on this for reference?
|
|
|
|
|
Is there any way by which i can read the Data that is been sent or receieved on a Port ?
Thanks
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
|
Bryce thanks for replying but
i just want to know how hard is to code an application like that or should i just drop the idea ?
i have to modify the HTML in a browser i am using BHO for that but was evaluating other options as well
you have some suggestions ?
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
there are some ways, but i don't know if they aren't quite complicated for you.
you could create a winsock service provider(WSP), you could code a global hook for the socket functions or the best way, you could create a tdi filter driver, which is quite difficult and a lot of work.
greez,
Alexander M.
Don't try it, just do it!
|
|
|
|
|
Hello All,
You can download the TDIMon utility from SysInternals :
http://www.sysinternals.com/ntw2k/freeware/tdimon.shtml
This tool is very useful indeed and is downloadable for free. It is very good by itself but I think the more advanced features will need to be purchased.
No source codes provided in the free version.
Hope this helps,
Bio.
|
|
|
|
|
theres a library on sourceforge (whos name i forget) that you can use in your apps to do stuff like that.
Alternatively look at SF and find a packet sniffer and look at their code
bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
Check out htmlfilter, this program filters out the commands that create popup windows, but I'm sure it wouldn't be hard to modify for what you need.
http://www.codeproject.com/tools/htmlfilter.asp?target=
|
|
|
|
|
I want to make a textcontrol object as in MSPaint..It should act as an object and must be movable and resizable...Please help me out.. ITS URGENT....
|
|
|
|
|
Hi,
I need to enumerate the process (names), that is running the current user on a terminal server (the user starts his terminal "client", then starts my application and I need to know if some processes are running or not).
I have tried to enumerate the processes names in a normal way, but then it gives me all the processes from all the sessions .
Thanks in advance, Greetings
Braulio
|
|
|
|
|
You can use WTSEnumerateProcesses(), which take WTS_PROCESS_INFO structure as one of its parameter.
where you can specify session id.
The session ID can be obtained from a variety of APIs including ProcessIdToSessionId, WTSQuerySessionInformation, or WTSEnumerateProcesses.
greatest thing is to do wot others think you cant suhredayan@omniquad.com
|
|
|
|
|
What is the particular problem with your program? Does it compile or is it a problem when running it?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I've problems when compiling.I think it needs 1 or 2 changes but I couldn't find.Can someone please help to figure it out?
Thanks
|
|
|
|
|
I've tried to compile and it gives the following errors:
(31) : error C2001: newline in constant The expression while(k!='\'); is incorrect: remember \ inside a literal string is a escape character. Maybe you mean '\\' (single backslash) or '\'' (single quote).
(66) : error C2440: 'initializing' : cannot convert from 'char []' to 'char'
(68) : error C2440: '=' : cannot convert from 'char' to 'char []' These are obvious: temp is not the same type as str or str2 .
After these new errors will ensue: keep posting if you cannot handle them after some examination.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
The 'count()' function is correct. Your call
int keer=count(str,s);
is looking for the character stored on s.
I think you want
int keer=count(str,'s');
This will count the 's' characters in the string str. You can get rid of the in s variable unless you want to be able to change it in the future. If this is the case assign the character 's' to the variable s and leave the call alone
int s='s';
In the 'swap()' function you are copying the addresss of the string NOT the string. The local container should be an array large enough for the string and the strings should be copied NOT assigned. Check the standard 'C' function 'strcpy()'. Your call will need to pass the string sizes. If you are not using the string size parameters to 'swap()' you should dispense with them. The declaration and definition header would look like: void swap(char str[], char str2[]);. You have already made certain that they will fit in the allotted storage (60 characters or less). The code in the 'swap()' function should look something like:
char temp[61];
strcpy(temp, str);
strcpy(str, str2);
strcpy(str2, temp);
|
|
|
|
|
In addition to Joaquín's suggestions, you need to look at the swap() function. It is expecting 4 parameters, but is only being called with two. The count() function is expecting a char for a second parameter, but is being called with an int . It also needs to return a value. The sentence() function also needs to return a value.
None of this should come as a big surprise to you as the compiler should have told you what was wrong.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
|
For text handling in GDI.
How do I draw text from right to left? Normal text are from left to right.
thanks
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Use the following flag in your DrawText(...) call
DT_RTLREADING - Layout in right-to-left reading order for bi-directional text when the font selected into the hdc is a Hebrew or Arabic font. The default reading order for all text is left-to-right.
|
|
|
|
|
i have two dialog boxes dialog1 and dialog2.when i click on the ok button of dialog1 i wnat to display dialog2 window.how do i do it
|
|
|
|
|
Here ...
CDialog1 Dlg1;
if (IDOK == Dlg1.DoModal())
{
CDialog2 Dlg2;
Dlg2.DoModal();
}
Best regards,
Eugene Pustovoyt
|
|
|
|
|
in the button event handler of dialog 1,
do this
dialog2 dlg;
dlg.DoModal();
//you need to inlcude the header file of the dialo2
I Touched Osama Bin Ladens Bushy Beard
|
|
|
|
|
Here sample of a code to gets a page through proxy with authorizing. First ::HttpSendRequest call returns success, but second call after proxy authorization is wedging. Why!? Where is mistake!?
HINTERNET hOpenHandle, hConnectHandle, hResourceHandle;
DWORD dwError, dwStatus;
DWORD dwStatusSize = sizeof(dwStatus);
hOpenHandle = ::InternetOpen("Example", INTERNET_OPEN_TYPE_PROXY, strProxyName, NULL, 0);
if (NULL != hOpenHandle)
{
hConnectHandle = ::InternetConnect(hOpenHandle, "www.microsoft.com", INTERNET_INVALID_PORT_NUMBER, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
if (NULL != hConnectHandle)
{
hResourceHandle = ::HttpOpenRequest(hConnectHandle, "GET", "", HTTP_VERSION, NULL, 0, INTERNET_FLAG_DONT_CACHE, 0);
if (NULL != hResourceHandle)
{
resend:
BOOL bSendRequest = ::HttpSendRequest(hResourceHandle, NULL, 0, NULL, 0);
::HttpQueryInfo(hResourceHandle, HTTP_QUERY_FLAG_NUMBER | HTTP_QUERY_STATUS_CODE, &dwStatus, &dwStatusSize, NULL);
switch (dwStatus)
{
case HTTP_STATUS_PROXY_AUTH_REQ:
InternetSetOption(hResourceHandle, INTERNET_OPTION_PROXY_USERNAME, (LPVOID)(LPCTSTR)strProxyUsername, strlen(strProxyUsername)+1);
InternetSetOption(hResourceHandle, INTERNET_OPTION_PROXY_PASSWORD, (LPVOID)(LPCTSTR)strProxyPassword, strlen(strProxyPassword)+1);
goto resend;
break;
case HTTP_STATUS_DENIED:
InternetSetOption(hResourceHandle, INTERNET_OPTION_PROXY_USERNAME, (LPVOID)(LPCTSTR)strProxyUsername, strlen(strProxyUsername)+1);
InternetSetOption(hResourceHandle, INTERNET_OPTION_PROXY_PASSWORD, (LPVOID)(LPCTSTR)strProxyPassword, strlen(strProxyPassword)+1);
goto resend;
break;
}
if (HTTP_STATUS_OK == dwStatus)
{
}
::InternetCloseHandle(hResourceHandle);
}
::InternetCloseHandle(hConnectHandle);
}
::InternetCloseHandle(hOpenHandle);
}
Best regards,
Eugene Pustovoyt
|
|
|
|