D
Doug
I've worked around this problem but it's still bugging me a bit so I
thought I'd ask here. In a derived class, I wanted to hold a reference to
a newly created object passed to a parent constructor. The only public
constructor in the parent requires this argument and the parent provides no
methods to later retrieve it. I couldn't find a syntax that would compile.
I'm thinking it's not possible but just wanted to confirm that I wasn't
missing something.
class someobject {}
class parent {
public parent (someobject so) { }
}
class child extends parent {
// someobject so = new someobject(); // Doesn't work
public child () {
// someobject so = new someobject(); // Also doesn't work
super (new someobject ()); // Want to hold a reference
// to someobject in child
}
}
Thanks in advance for any answers.
Doug
thought I'd ask here. In a derived class, I wanted to hold a reference to
a newly created object passed to a parent constructor. The only public
constructor in the parent requires this argument and the parent provides no
methods to later retrieve it. I couldn't find a syntax that would compile.
I'm thinking it's not possible but just wanted to confirm that I wasn't
missing something.
class someobject {}
class parent {
public parent (someobject so) { }
}
class child extends parent {
// someobject so = new someobject(); // Doesn't work
public child () {
// someobject so = new someobject(); // Also doesn't work
super (new someobject ()); // Want to hold a reference
// to someobject in child
}
}
Thanks in advance for any answers.
Doug