|
rp_suman wrote: How to check the instance of the class is valid
What do you mean exactly ? Can you be more explicit please. What does 'valid' mean ?
|
|
|
|
|
Suman,
Plz give more deatils....what is actually men by 'valid'.
It will be better if u provide with some code fragment that u are using.....
Prasanth
|
|
|
|
|
HI,
Plz give more deatils....what is actually mean by 'valid'.
It will be better if u provide with some code fragment that u are using.....
prasanth
|
|
|
|
|
Hi Prasanth, you replied to the wrong person.
Maxwell Chen
|
|
|
|
|
Maxwell Chen wrote: you replied to the wrong person.
How dare you call Cedric a wrong person!
|
|
|
|
|
Rajesh R Subramanian wrote: How dare you call Cedric a wrong person!
Maxwell Chen
|
|
|
|
|
He might have meant different person,
Best Regards,
Suman
|
|
|
|
|
There's a thing called pun. And one more thing called "the joke icon".
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
For example, if we create some object using new() and call delete(), the object will be deleted.
I want to avoid the use of the object before new() and after delete().
Can we check like if(object != NULL) or else?
BTW:
Sorry for delay I posted just before leaving office, now seeing from my room.
Best Regards,
Suman
|
|
|
|
|
Yes, just set the pointer to NULL in your constructor and once you delete the object, just set it to NULL again.
|
|
|
|
|
So, I can check the object is not NULL before accessing it.
Thanks & Regards,
Suman
|
|
|
|
|
Onlyl if you are working with pointers because if you are working with objects directly, they are always "valid" (except if you did something really wrong, but anyway, there's no way to test it).
|
|
|
|
|
Hi Cedric, you are right..
Thanks for the great help!!
Best Regards,
Suman
|
|
|
|
|
rp_suman wrote: How to check the instance of the class is valid or it is not especially in multi threaded program?
is that pointer to class or simple object!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Simple object and also pointer.
Thanks & Regards,
Suman
|
|
|
|
|
How's life, Alok? (Brahmma here... Changed the CP display name to my real name)
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
ffine buddy.. what abt you
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Me doing good, Alok. Thanks.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
The whole essence of an object is that it knows about itself. Add an IsValid() method to the class. When that method is invoked, the object can check the validity of each of its members.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
IsValid () is defined in which class of C++?
Thanks & Regards,
Suman
|
|
|
|
|
Did you miss the "Add an IsValid() method to the class" part?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, so you mean IsValid() is the user defined method?
I have doubt, can we check the object of CStringList is valid like if(object != NULL) ?
Thanks & Regards,
Suman
modified on Friday, February 15, 2008 11:51 AM
|
|
|
|
|
Hello everyone,
Could anyone post or let me know where is the definition of ITypeInfo please?
(my purpose is to find its inheritance relationship, i.e. whether inherits from IUnknown or something)
I searched all VC sub-directory and only get (in afxstat_.h),
struct ITypeInfo;
typedef ITypeInfo* LPTYPEINFO;
thanks in advance,
George
|
|
|
|
|
Oaidl.h ?
George_George wrote: where is the definition of ITypeInfo please
u mean declaration
George_George wrote: my purpose is to find its inheritance relationship, i.e. whether inherits from IUnknown or something)
yes it inherits from IUnknown
|
|
|
|
|
Thanks Rajkumar,
Cool, I have found it from Oaidl.h. I am interested that Oa is short for?
MIDL_INTERFACE("00020401-0000-0000-C000-000000000046")
ITypeInfo : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE GetTypeAttr(
TYPEATTR **ppTypeAttr) = 0;
virtual HRESULT STDMETHODCALLTYPE GetTypeComp(
ITypeComp **ppTComp) = 0;
virtual HRESULT STDMETHODCALLTYPE GetFuncDesc(
UINT index,
FUNCDESC **ppFuncDesc) = 0;
virtual HRESULT STDMETHODCALLTYPE GetVarDesc(
UINT index,
VARDESC **ppVarDesc) = 0;
virtual HRESULT STDMETHODCALLTYPE GetNames(
MEMBERID memid,
BSTR *rgBstrNames,
UINT cMaxNames,
UINT *pcNames) = 0;
virtual HRESULT STDMETHODCALLTYPE GetRefTypeOfImplType(
UINT index,
HREFTYPE *pRefType) = 0;
virtual HRESULT STDMETHODCALLTYPE GetImplTypeFlags(
UINT index,
INT *pImplTypeFlags) = 0;
virtual HRESULT STDMETHODCALLTYPE GetIDsOfNames(
LPOLESTR *rgszNames,
UINT cNames,
MEMBERID *pMemId) = 0;
virtual HRESULT STDMETHODCALLTYPE Invoke(
PVOID pvInstance,
MEMBERID memid,
WORD wFlags,
DISPPARAMS *pDispParams,
VARIANT *pVarResult,
EXCEPINFO *pExcepInfo,
UINT *puArgErr) = 0;
virtual HRESULT STDMETHODCALLTYPE GetDocumentation(
MEMBERID memid,
BSTR *pBstrName,
BSTR *pBstrDocString,
DWORD *pdwHelpContext,
BSTR *pBstrHelpFile) = 0;
virtual HRESULT STDMETHODCALLTYPE GetDllEntry(
MEMBERID memid,
INVOKEKIND invKind,
BSTR *pBstrDllName,
BSTR *pBstrName,
WORD *pwOrdinal) = 0;
virtual HRESULT STDMETHODCALLTYPE GetRefTypeInfo(
HREFTYPE hRefType,
ITypeInfo **ppTInfo) = 0;
virtual HRESULT STDMETHODCALLTYPE AddressOfMember(
MEMBERID memid,
INVOKEKIND invKind,
PVOID *ppv) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateInstance(
IUnknown *pUnkOuter,
REFIID riid,
PVOID *ppvObj) = 0;
virtual HRESULT STDMETHODCALLTYPE GetMops(
MEMBERID memid,
BSTR *pBstrMops) = 0;
virtual HRESULT STDMETHODCALLTYPE GetContainingTypeLib(
ITypeLib **ppTLib,
UINT *pIndex) = 0;
virtual void STDMETHODCALLTYPE ReleaseTypeAttr(
TYPEATTR *pTypeAttr) = 0;
virtual void STDMETHODCALLTYPE ReleaseFuncDesc(
FUNCDESC *pFuncDesc) = 0;
virtual void STDMETHODCALLTYPE ReleaseVarDesc(
VARDESC *pVarDesc) = 0;
};
regards,
George
|
|
|
|