Home > Archive > VC STL > February 2006 > initializing structure with a Cstring object
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
initializing structure with a Cstring object
|
|
| Rajitha 2006-02-13, 7:05 pm |
| Hi,
I dont understand where I'm going wrong but when I run the following code,
it gives me an error saying "QEntries[i]->m_pchData" has no value
("expression cannot be evaluated"). Can somebody help please!
code:
struct structQueueEntry
{
structQueueEntry(LPCTSTR timecode, LONGLONG
frame):m_dTimecodeEntry(timecode), m_nFrameNumber(frame) {};
CString m_dTimecodeEntry;
LONGLONG m_nFrameNumber;
};
static int MAXSIZE=10000000;
class CMyQueue
{
private:
structQueueEntry *QEntries;
public:
CMyQueue(){
for(int i=0; i<MAXSIZE; i++){
ERROR---------- QEntries[i] = structQueueEntry(" ", 0); }
}
};
| |
| Igor Tandetnik 2006-02-13, 7:05 pm |
| Rajitha <Rajitha@discussions.microsoft.com> wrote:
> I dont understand where I'm going wrong but when I run the following
> code, it gives me an error saying "QEntries[i]->m_pchData" has no
> value ("expression cannot be evaluated"). Can somebody help please!
>
> code:
>
> struct structQueueEntry
> {
> structQueueEntry(LPCTSTR timecode, LONGLONG
> frame):m_dTimecodeEntry(timecode), m_nFrameNumber(frame) {};
> CString m_dTimecodeEntry;
> LONGLONG m_nFrameNumber;
> };
>
> static int MAXSIZE=10000000;
>
> class CMyQueue
> {
> private:
> structQueueEntry *QEntries;
> public:
> CMyQueue(){
> for(int i=0; i<MAXSIZE; i++){
> ERROR---------- QEntries[i] = structQueueEntry(" ", 0); }
> }
> };
I don't see you allocate any memory for QEntries. As far as I can tell,
QEntries pointer points to garbage.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
| Rajitha 2006-02-13, 7:05 pm |
| Thanks Igor. I'm sorry I didn't post my question correctly. I did initialize
my pointer objects. Anyways, I could figure it out myself.
Thanks.
"Igor Tandetnik" wrote:
> Rajitha <Rajitha@discussions.microsoft.com> wrote:
>
> I don't see you allocate any memory for QEntries. As far as I can tell,
> QEntries pointer points to garbage.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
|
|
|
|
|