Really? I've used the cast from an example. I want to use std::string
because it is more flexible than CString. When I parse and extract data from
a XML file, it gives me _bstr_t type. From _bstr_t, how can I safely convert
Appreciate much.
"thejackofall" <thejackofall@discussions.microsoft.com> ha scritto nel
messaggio news:039D0EC2-4DFD-4FEA-BBF9-FFC150828DFE@microsoft.com...
Here is my constructor and the rest. I am really puzzled about this.
#include "InsertDependency.h"
InsertDependency::InsertDependency()
{
_ID = "";
_MustBeforeLink = "";
}
InsertDependency::InsertDependency(string ID, string MustBeforeLink)
{
_ID = ID;
_MustBeforeLink = MustBeforeLink;
}
Is 'string' the std::string?
In your first post in the thread you wrote:
InsertDependency* pInsertDependency = new InsertDependency((LPCTSTR) ID,
(LPCTSTR) MustBeforeLink);
in this case the LPCTSTR cast is wrong.
If you want LPCTSTR strings, you may consider using CString from ATL/MFC
instead of std::string...
string& InsertDependency::GetID()
{
return (_ID);
}
I would define a const GetXxxx method, e.g.
LPCTSTR InsertDependency::GetID() const
{
return ((LPCTSTR) _ID); // assume "CString _ID" data member
}
If you want to modify the string values, you can implement a separate
SetXxxxx method.
Giovanni