How do you inherit a class in a class?
myclass: subclass
???
right now all we have to my knowledge is
myclass :: myclass()
{
}
would it be
myclass :: myclass() : subclass
??
class First
{
declare First( ) { print( "First::First( )" ); }
declare virtual Stuff( ) { print( "First::Stuff( )" ); }
}
class Second : First
{
declare Second( ) { print( "Second::Second( )" ); }
declare virtual Stuff( ) { print( "Second::Stuff( )" ); }
}
global sub main( )
{
First *c = new( First, 1 );
c->Stuff( );
delete c;
print( "----" );
c = new( Second, 1 );
c->Stuff( );
delete c;
}
Alternatively
//...
class Second : First
{
declare Second( );
declare virtual Stuff( );
}
Second::Second( )
{
print( "Second::Second" );
}
Second::Stuff( )
{
print( "Second::Stuff" );
}
//...
What exactly do you mean by "inherit a class in a class"? What I've shown is the only way things work in all OOP languages (except multiple inheritance and interfaces, but I'm pretty sure that's not what you're talking about).
You inherit a class in the defintion, not the implementation, just as you do in C++
class myclass : CWindow
{
}
But I have the feeling your asking something else. If yoru refering to virtual funcitons that is handled automatically, if yoru class is derived from CWindow you can call any method that exists in CWindow.
What is it you're asking?
[Edit] parker beat me to it. Must be getting slow.
Thanks next question.
dMatrix &matrix
What is its equivelent for the &matrix?
Parkers answer was snap on what I needed for the first question, not viruals.
thanks :)
That's a reference. You can use a pointer and make sure you dereference it each time you use it.
C++:
SomeClass &c = ...;
c.doStuff( );
Aurora:
SomeClass *c = ...;
c->doStuff( );
Thanks parker, don't beat on me to hard guys, I have had a long day trying to get the Newton thing working.
Now I am converting headers to test the main newton.inc I created, since I know I tested most of the initial stuff just by calling it to see if it broke and it didn't.
Now I want to make it work, so running into these little roadblocks during translation.
Just trying to help.
This has been killing me all day...
What is
unsigned
in aurora?
nevermind, its an unsigned INT
or int64 in aurora I guess..
Also here is another one, in a definition how do I assign a default?
For instance:
RenderPrimitive :: RenderPrimitive(dSceneNode *parent, dMatrix *matrix, int texture = -1)
{
}
This is obvsiouly in my SRC file.
Has to be in the declare, just use the 'opt' keyword.
declare RenderPrimitive(dSceneNode *parent, dMatrix *matrix, opt int texture = -1);
RenderPrimitive :: RenderPrimitive(dSceneNode *parent, dMatrix *matrix, opt int texture = -1)
{
}
Thanks, going to add 2 more files over on the Newton discussion.