Re: LPCTSTR: whats going wrong here?
..rhavin grobert wrote:
i.e. you need something that properly manages your character data (LPCTSTR),
and CString does a good job about that.
for what reason? all stayes inside the same dll. to abstact it:
we have class A with member CString m_scA and an inline method
inline LPCTSTR A::GetA() {return m_scA;};
we have class B : public A with member CString m_scB and an inline
method
inline LPCTSTR A::GetWhatever(bool fChoose) {
return ( fChoose ? m_scB : GetA() );
};
...as GetA() is inline this should equal...
inline LPCTSTR A::GetWhatever(bool fChoose) {
return ( fChoose ? m_scB : m_scA);
};
for what reason do i need a ctor/dtor?
..rhavin:
Because GetA() returns a LPCTSTR, and the type of your ternary expression is a
CString (determined by m_scB).
If you wrote
inline const CString& A::GetA() const {return m_scA;}
then you would have no copying and I think your code would work.
--
David Wilkinson
Visual C++ MVP