I cannot clearly state my problem in the title but this is really it.
void DChatbox::ClampObject(DTextbox _txtbox) {
this->_txtbox = &_txtbox;
}
this one just create a copy of _txtbox not referencing it.
but this one works.
void DChatbox::ClampObject(DTextbox* _txtbox) {
this->_txtbox = _txtbox
}
as I examined the first one, it just makes a copy of it, not referencing it. Why is it like that?
note: _txtbox on DChatbox is declared as this DTextbox* _txtbox
DTextbox &_txtbox.pointers and reference are different.DTextbox _txtboxshould beDTextbox &_textbox, don't you? The second example is correct, while the first assigns the memory address of a local variable (which is on the stack).this->_txtboxwill not point to a validDtextboxobject