E
eric
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
but it can not compile success
--------------------
Example14-10.cpp: In function ‘int main()’:
Example14-10.cpp:38:7: error: ‘DOMPtr<T>:
OMPtr(const DOMPtr<T>&)
[with T = xercesc_2_8:
OMBuilder, DOMPtr<T> =
DOMPtr<xercesc_2_8:
OMBuilder>]’ is private
Example14-10.cpp:94:111: error: within this context
Example14-10.cpp:38:7: error: ‘DOMPtr<T>:
OMPtr(const DOMPtr<T>&)
[with T = xercesc_2_8:
OMWriter, DOMPtr<T> =
DOMPtr<xercesc_2_8:
OMWriter>]’ 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)
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 said:createDOMWriter(); // this 140
but it can not compile success
--------------------
Example14-10.cpp: In function ‘int main()’:
Example14-10.cpp:38:7: error: ‘DOMPtr<T>:
[with T = xercesc_2_8:
DOMPtr<xercesc_2_8:
Example14-10.cpp:94:111: error: within this context
Example14-10.cpp:38:7: error: ‘DOMPtr<T>:
[with T = xercesc_2_8:
DOMPtr<xercesc_2_8:
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)