How to forward delare CArray class ?
-
Hi All, I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file. Is there any method to forward delare CArray class? Thankx in advance.
-
Hi All, I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file. Is there any method to forward delare CArray class? Thankx in advance.
VCSharp007 wrote:
I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file
IMHO you cannot satisfy the above requirement. :)
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.
-
Hi All, I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file. Is there any method to forward delare CArray class? Thankx in advance.
VCSharp007 wrote:
I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file.
// Forward declare CArray.
template<class TYPE, class ARG_TYPE> class CArray;class SomeClass
{
public:
// No need to include afxtempl.h
CArray<float, float>* pFloatArray = 0;
};
Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com
-
Hi All, I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file. Is there any method to forward delare CArray class? Thankx in advance.
This is a bad requirement, because than is the dependency unclear.:suss: Remember: Write selfexplaining code, so you dont need to document the code. You can also include the afxtempl.h in another header. stdafx.h is a good place because, the afxtempl.h wont be change a lot of times.
Greetings from Germany
-
VCSharp007 wrote:
I have a requirement to add a CArray member varibale in my class without including afxtempl.h in my class header file.
// Forward declare CArray.
template<class TYPE, class ARG_TYPE> class CArray;class SomeClass
{
public:
// No need to include afxtempl.h
CArray<float, float>* pFloatArray = 0;
};
Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com
Thanks Nibu. But I have to use CArray varibale not pointer!!!!
-
Thanks Nibu. But I have to use CArray varibale not pointer!!!!
VCSharp007 wrote:
But I have to use CArray varibale not pointer!!!!
No then forward declaration won't work, since classes should know their sizes. Pointer is ok since size will be sizeof a pointer. Forward declaration just tells the compiler that the class is ok and definition of that is readily available somewhere. So it searches for the given class when code for the parent class is being generated. Otherwise include "afxtempl.h" in precompiler header file. But then again there will be issues when this header file is being used somewhere else where there is no precompiled header file.
Nibu thomas A Developer Code must be written to be read, not by the compiler, but by another human being. http:\\nibuthomas.wordpress.com