Calling a struct constructor in a class constructor body
From: Karl M (Karl.M_at_email.com)
Date: 12/18/04
- Next message: Peter Schmitz: "Performance analysis"
- Previous message: Russell Mangel: "Re: VC++ vs C#"
- Next in thread: Carl Daniel [VC++ MVP]: "Re: Calling a struct constructor in a class constructor body"
- Reply: Carl Daniel [VC++ MVP]: "Re: Calling a struct constructor in a class constructor body"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 18 Dec 2004 05:41:34 -0500
Hi C++ experts!
Definitely I skipped C/C++ 101 because I have this pitfall:
I need to call the struct ctor in the class default ctor body see below:
//Some.h
struct MyStruct
{
int a[5];
.
};
class MyClass
{
public:
MyClass();
~MyClass();
.
protected:
.
MyStruct m_MyStruct;
.
};
//some.cpp
#include "some.h"
MyClass::MyClass() : m_MyStruct()
// default ctor of the struct with NULL- it works but not with the order of
class member declarations I have, so...
{
// here I need to have m_MyStruct() initialized with NULL not
using m_MyStruct.a[1] = 0; etc .
//How? Or maybe.m_MyStruct = MyStruct(); I this correct?
}
It's painful, now I understand VB programmers - easy street :)
Thank you,
Karl M
- Next message: Peter Schmitz: "Performance analysis"
- Previous message: Russell Mangel: "Re: VC++ vs C#"
- Next in thread: Carl Daniel [VC++ MVP]: "Re: Calling a struct constructor in a class constructor body"
- Reply: Carl Daniel [VC++ MVP]: "Re: Calling a struct constructor in a class constructor body"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|