compile error on constructor/private
Dear C/g++ experts:
I declare the following
--------------------------------------------------------
template<typename T>
class DOMPtr {
public:
DOMPtr(T* t) : t_(t) { }
~DOMPtr() { t_->release(); }
T* operator->() const { return t_; }
private:
// prohibit copying and assigning
DOMPtr(const DOMPtr&); // this is my line 38
DOMPtr& operator=(const DOMPtr&);
T* t_;
};
---------------------------------------------------------------------------=
----
then use it here
----------------------------------------------------------
DOMPtr<DOMBuilder> parser =
static_cast<DOMImplementationLS*> // this is 94
(impl)->createDOMBuilder(DOMImplementationLS::MODE_SYNCHRONOUS, 0);
-------------------
// Construct a DOMWriter to save animals.xml
DOMPtr<DOMWriter> writer =
static_cast<DOMImplementationLS*>(impl)-
createDOMWriter(); // this 140
-----------------------
but it can not compile success
--------------------
Example14-10.cpp: In function =91int main()':
Example14-10.cpp:38:7: error: =91DOMPtr<T>::DOMPtr(const DOMPtr<T>&)
[with T = xercesc_2_8::DOMBuilder, DOMPtr<T> =
DOMPtr<xercesc_2_8::DOMBuilder>]' is private
Example14-10.cpp:94:111: error: within this context
Example14-10.cpp:38:7: error: =91DOMPtr<T>::DOMPtr(const DOMPtr<T>&)
[with T = xercesc_2_8::DOMWriter, DOMPtr<T> =
DOMPtr<xercesc_2_8::DOMWriter>]' is private
Example14-10.cpp:140:70: error: within this context
---------------------------------------------------------------------------=
----------------------------------------------
it looks my instantiate go through private as well as constructor(or
not go through constructor at all),
which is out of expectation
need your help/hint/suggestion on how to fix it, and not deviate from
origin textcontext of book author
(c++ cookbook)(you can download the code from
http://examples.oreilly.com/9780596007614/
on 14-10.cpp, and animals.xml at 14-1.xml, to test by yourself
thanks a lot in advance, Eric(g++4.5.2, linux2.6.38-10)