|
I am creating a general purpose linked list class.
It is basically used for numbers. In that case no problem.
I intended to use it for strings also. In that case the AddNode function is supposed to accept 'const char*' as input. In the template class I wrote some virtual functions that can be used for allocating memory for the strings, in the derived classe.
For example, in AddNode I will call a function like
virtual void SetVal(...);
In the base class, this function just copies the input value to the node value. But in the derived class, it will allocate memory needed for storing the input string to node value and copy the string using strcpy(...).
I think, you got what I want to do. I won doing this by excluding the const input string. But it is recommented that pass input strings as read only.
- NS -
|
|
|
|
|
<br />
template < typename T > class DataList<br />
{<br />
public:<br />
AddNode(const T val)
{<br />
}<br />
};<br />
<br />
<br />
IN Main function <br />
<br />
LPCSTR str = "Hello";
DataList< char *> data;
data.AddNode((char*)str);
the above code satisfies your demand , i just type casted the LPCSTR to char *
and to access the AddNode declared it with Public scope .
If u want to check just try changing the { val="v";} u will see an compiler
error for constant.
//////////////////////////////////////////////////////////////////////
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I'm sorry, it will make every call to this function need a typecast, which is not acceptable...
Further more the input data is not sefe.
You wrote:
val="v";
In this, the pointer, val is become a const, that's why we cannot assign another pointer("v") to it. But we can change the contents, for example *val = 'a' or strcpy(val,"hi") is possible.
- NS -
|
|
|
|
|
template < typename T > class DataList<br />
{<br />
public:<br />
AddNode(const T val)
{<br />
*val='a';<br />
}<br />
};<br />
<br />
<br />
In Main function <br />
<br />
LPCSTR str = "Hello";
DataList<const char *> data;
data.AddNode(str); <br />
Now in this code there is not type casting and also
the *val='a' ; condtion is satisfied .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I'm afraid that you forgot my problem. Actually our discussion reached exactly at where we start from.
Could you please read it agian?
- NS -
|
|
|
|
|
replace LPCSTR with LPSTR.
you instantiate a DataList specialization on char* parameter, but you send incorrect parameter type to AddNode().
AddNode expect constant instance of type T (therefore, constant pointer to char, or char* const),
but you send a pointer to constant char (const char*).
although the syntax looks similar, semantics is quite different. please look it up in language reference.
hope this helps
-- modified at 6:06 Tuesday 20th December, 2005
of course, be aware that literal strings can't really be modified because they are placed in protected part of memory (executable image), so if you write
LPSTR str = "Hello";
str[1] = 'a';
you will get an access violation.
-- modified at 6:15 Tuesday 20th December, 2005
|
|
|
|
|
I think its because you are declaring:
DataList<char*> data;
And then using LPCSTR with it.
A char* is a pointer to a list of characters, terminated by NULL, while LPCSTR 's declaration is:
typedef CONST CHAR *LPCSTR, *PCSTR;
I think changing DataList<char*> data; to DataList<LPCSTR> data; etc should solve the problem.
this is this.
|
|
|
|
|
Hi to all,
I am having more than 20 dlls for my application. if i want to store those dlls in one folder and use them while running the application what i have to do?
For example all header files if I copy in one folder and giving this folder name in include folders of Tools->Options then it works fine. Is there any method like this for Dlls. Please help me.
Thanks in advance.
|
|
|
|
|
ActiveX Controls Test Container saves file as .tcs. If Activex Control is placed anywhere in container and save it and next time if we open that .tcs file activex controls are placed on same locations as it was at the time of saving in .tcs file. I want to implement this functionality (drag & Drop of activex controls in application)in my project. so how should i do this or if any other solution is there for this problem or if anybody could give me file format of this .tcs file of ActiveX Controls Test Container.
|
|
|
|
|
Hi,
This is Trinadh. I am VC++ developer in AxSys HealthTech Ltd. Now there is a requirement in my company is to Use PlugTransport.exe (Micrsoft NetMeeting SDK Sample) within Service. When i am trying to use PlugTransport.exe in Service, i am getting problem at hr = m_pINmMgr->Initialize(&uOptions,&uCaps); in nmsession.cpp statement. The problem is i am unable to get SUCCESS or FAILURE of hr even i am using winerror.h in PlugTransport.dsw. This Method unable to return any value when i am using PlugTransport.exe within service.
With this problem i am unable to stop Service and PlugTransport.exe, conf.exe are unable to delete from TaskManager and those are becoming Access Denied.
Now there is urgent requirement in my company to use PlugTransport.exe with in service.
Kindly let me know the reason for this. I am waiting for your fast response.
Regards
Trinadh
|
|
|
|
|
Hi
i am a newbie to VC++ . I do have a requirment ..but i dont how to start that ..
My requirment is my program need to send a message to client program whenever a window flashes in my desktop ( for example if any new message comes from Yahoo messenger my program need to capture that .. ). Its a bit urgent .Pls help me
|
|
|
|
|
coolsab wrote: My requirment is my program need to send a message to client program whenever a window flashes in my desktop ( for example if any new message comes from Yahoo messenger my program need to capture that .. ).
Set System wide Hook for WM_CREATE, WM_SHOWWINDOW for Yahoo Messenger popup window... here in the article will help you to achieve same :-
http://www.codeproject.com/system/hooksys.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Check out the windows hook fundamentals
that can help u ?
but if there are some spyware prevension
software installed hooks might not work
properly.
ok
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
is it possible to read index server catalogs??
pls help its urgent
|
|
|
|
|
Hi,
We can not kill the system processes (eg. System, Services.exe etc) trhu Terminateproc API, am I right??? Also for System processes we dont get handle when we try to get it from 'openprocess' API...
do let me know..
Thanks
Supriya Tonape
|
|
|
|
|
Why don't you just shutdown Windows, instead of try to kill it's vital processes?
|
|
|
|
|
I wanted to terminate the process thru my appln, so cant shutdown windows
seems, didnt get my prob, by Ur way after restarting PC again those SYSTEM processes wud get started...hope U got that
thanks
Supriya Tonape
|
|
|
|
|
Supriya Tonape wrote: We can not kill the system processes (eg. System, Services.exe etc) trhu Terminateproc API, am I right??? Also for System processes we dont get handle when we try to get it from 'openprocess' API...
Yeah you can kill the these process, but for killing that process you should be havinf SYSTEM priviledge.. Only services running in your computer can run on this priviledge.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks Alok, Even if U have those privileges(me not very sure abt this privileges) U cant kill SYSTEM processes since they are necessary n if U will kill it manually from TASK Manager Ur PC wud get rebooted.
But anyways, I got the solution, like GetLastError() returns me "E_ACCESSDENIED" error and thats OK wid my appln
thanks
Supriya Tonape
|
|
|
|
|
Supriya Tonape wrote: Even if U have those privileges(me not very sure abt this privileges) U cant kill SYSTEM processes since they are necessary
Yeap you can kill them... because I myself have done that.....
Supriya Tonape wrote: since they are necessary n if U will kill it manually from TASK Manager Ur PC wud get rebooted.
When i killed that application ... My system get unstable, not rebooted and after some time as precaution measure Windows have restarted these process with new PID.
check this site.. i hope it still working http://www.securenm.com that application is using similiar concept
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Supriya Tonape wrote: Even if U have those privileges(me not very sure abt this privileges) U cant kill SYSTEM processes since they are necessary
AFAIK, I myself created Service that can kill these process.... secondly at that time my system don't get rebooted but it get unstable.. and Windows Reexecute this process to make system stable....
Check out that software at http://www.securenm.com, i am not sure that site is still up
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
It might be, By the way I was talking abt SYSTEM PROCESS n not service if U see my last mail.
thanks n regards
Supriya Tonape
|
|
|
|
|
Supriya Tonape wrote: It might be, By the way I was talking abt SYSTEM PROCESS n not service if U see my last mail.
Calm Down MADAME, sorry if I sound rude.. have you ever heard about SERVICES...? if not let me explain them, they are normal exe but with speacial features, they don't need any user account to run it, i.e. it runs under SYSTEM ACCOUNT, ever before you login your PC (yeap)...
So I hope you got my point, I just want to provide you information, MADAME.. Just a community service....
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks.wud like to reply U my view points but no time.Anyways bye
regrads
Supriya Tonape
|
|
|
|
|
Hi Everybody,
1.What are relocatable dlls exactly?
2.Under what condition one had to use them?
3.How they differ from standard Windows DLL
Thanks
Abhi Lahare
|
|
|
|