Menuplugin Constructor
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/03/2006 at 13:17, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 9.5
Platform: Windows ;
Language(s) : C.O.F.F.E.E ;---------
Hi, I'm trying to initialise some variables within the constructor of my class derived off the Menuplugin class, I cannot get this to work, in fact I can't even find out when it is called as the println function I inserted never seems to happen. Is this possible? -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/03/2006 at 13:38, xxxxxxxx wrote:
Code, please?
Thanks,
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/03/2006 at 23:46, xxxxxxxx wrote:
Hi, yes sorry, thanks for your reply.
Basic example.
class myclass : menuplugin
{
private:
var a; // My own member variables that I want
var b; // to initialise when plugin is registered.
public:
myclass(); // constructor
}myclass::myclass()
{
super();//This is what I expected to work as it can in c++
println("Constructing myclass");
a = 2;
b = 3;
}I thought this would be the only way possible as coffee doesn't accept default arguments on functions as in c++ and can't think of a way to send arguments to this constructor as it's not envoked by me. This method works on my own classes. Am I missing something?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/03/2006 at 00:21, xxxxxxxx wrote:
Have you tried calling super() at the end of the method? This may (or may not) make a difference - for the C++ SDK, I call SUPER::xxxx() at the end:
//*---------------------------------------------------------------------------* Bool IPPMorph::Init(GeListNode* node) //*---------------------------------------------------------------------------* { morphsC = NULL; BaseContainer* bc = ((BaseTag* )node)->GetDataInstance(); if (!bc) return ErrorException::Throw(GeLoadString(ERROR_MEMORY_TEXT), "IPPMorph.Init.bc"); bc->SetLong(IPPMORPH_DELTACOUNT, 0L); bc->SetLong(IPPMORPH_SIZECOMPRESS, 0L); return SUPER::Init(node); }
You may not even need to call super(), unless there are member variables of the MenuPlugin class that you suspect need initializing - which I doubt. In my code above, the IPPMorph class is derived from my IPPDial class (derived from TagData). Otherwise, IPPDial doesn't call SUPER anything.
Comment out 'super();' and see what happens. Sometimes these things require less 'logic' and more 'methodical illogical consequential circumstances'. In other words, to quote Sherlock Holmes (ala Sir Arthur Conan Doyle), "... when you have excluded the impossible, whatever remains, however improbable, must be the truth." In other words, sometimes what appears to be completely logical in proceeding, may require exclusion of everything but the most essential to discover the real cause.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/03/2006 at 01:56, xxxxxxxx wrote:
Hi, thanks for the suggestions. Not calling super() gives me an error "super() expected in constructor" and changing the order doesn't work either. It's a bit frustrating because in the template for menuplugins that comes with the sdk it even has a//Todo: Initialise local variables here comment. Calling the base class constructor from the derived class constructor seems a bit strange to me. Anyway if I can't resolve this soon I will have to find another way to achieve what I want.
regards,
JDP -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/03/2006 at 02:21, xxxxxxxx wrote:
Calling the base class constructor from the derived class constructor is standard practice in OOP, though in C++, this is usually accomplished with something like this:
myclass::myclass(a, b) : baseclass(a, b)
{
...
}The base class is passed the initialization parameters of a and b which exist in the base class. If they exist in the derived class instead, this is not necessary. In other words, this construct is used to initialize the base classes members from the derived class. But you are initializing the derived class members which does not require such a construct.
Is it possible that COFFEE is not recognizing the initialization without passed parameters? Might have to leave this to Mikael to determine if it is a bug. Try passing the values as constructor arguments and see if that changes the situation.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 23/03/2006 at 03:20, xxxxxxxx wrote:
Hi, yes I'm familiar with all the different methods of member initialisation in c++, or I thought I was :). I just never thought of it that way because the base class constructor is fully created first before the derived class constructor, but it's obvious when you think about it that it has to work the way you say. I did try to pass the values as constructor arguments after my first method failed but that didn't work either. Maybe it is a bug, hopefully MiKael will enlighten us.