Re: help with constructor

Tech-Archive recommends: Speed Up your PC by fixing your registry



What if I want to call a constructor for another member variable, would I separate it from the other constructor with a comma or another colon?

--

Daniel



"Brian Muth" <bmuth@xxxxxxxx> wrote in message news:e6sqbeKYJHA.5108@xxxxxxxxxxxxxxxxxxxxxxx
It is calling the constructor for the m_psz member variable, and passing a pointer to some allocated memory as a value.

Note I can do this for other built-in variable types as well:

int i1= 5;
int i2 = int (5);
int i3 (5);

all do pretty much the same thing, in terms of declaring and assigning a value to a variable.




"Daniel" <falsename@xxxxxxxxxxxxxxx> wrote in message news:0815863E-AF25-44AE-9005-899C3E9CEE74@xxxxxxxxxxxxxxxx
What does the line do after the last colon below?

// faststring.h
class FastString {
char *m_psz
public:
FastString(const char *psz);

// faststring.cpp
FastString::FastString(const char *psz)
: m_psz(new char[strlen(psz) + 1]) {
}

--

Daniel


.



Relevant Pages