Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I get a piece of c++ example project. I copy a header file into myself project from the example project.the content of the header file is below:

C++
#ifndef _SAFEARRAYHELPER_H_
#define _SAFEARRAYHELPER_H_

class CSafeArrayHelper
{
	public:
		CSafeArrayHelper();
		~CSafeArrayHelper();

	bool Create(VARTYPE  vt, UINT  cDims, UINT lBound, UINT cCount);
	bool Destroy();
	UINT GetDimension();

	bool Attach(LPSAFEARRAY psa);
	bool AttachFromVariant(VARIANT* pVariant);
	LPSAFEARRAY Detach();
	LPSAFEARRAY GetArray();
	bool AccessData(void FAR* FAR* pvData);
	bool UnaccessData();
	bool Lock();
	bool Unlock();
	bool PutElement(long lIndices, void FAR* vData);
	bool GetElement(long lIndices, void FAR* vData);
	VARIANT GetAsVariant();

	protected:
	LPSAFEARRAY	m_pSA;

	private:
};

#endif // _SAFEARRAYHELPER_H_



and there are many error like that;
C++
1>g:\c++_code\driver1\safearrayhelper.h(10): error C2061: 语法错误: 标识符"VARTYPE"
1>g:\c++_code\driver1\safearrayhelper.h(12): error C2146: 语法错误: 缺少";"(在标识符"GetDimension"的前面)


But there is no error in the example.
why there are no definion of "VARTYPE" "LPSAFEARRAY",but there is no error in the exampl project.
-kkklko
Posted
Updated 13-Sep-13 3:30am
v2

1 solution

Because (probably) in the example project sources the _SAFEARRAYHELPER_H_ header is included below the ones containing the definitions of VARTYPE and LPSAFEARRAY.
 
Share this answer
 
v2
Comments
Richard MacCutchan 13-Sep-13 9:08am    
I think you mean above, or before.
CPallini 13-Sep-13 9:23am    
The OP header must be included below or after the type declarations it uses, am I wrong (I know my English is contrived)?
Richard MacCutchan 13-Sep-13 9:46am    
Correct, but look what you put in your solution. And I know your English is excellent.
CPallini 13-Sep-13 11:16am    
I tried to make it clearer.
By the way: the 'example project' is the one that compiles fine.
By the way (again), thank you, but I think my English is still poor.
Richard MacCutchan 13-Sep-13 12:28pm    
Yeah, it's my English that's poor today. :(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900