GLBasic forum

Main forum => GLBasic - en => Topic started by: sf-in-sf on 2012-Dec-13

Title: OOP quick tuto +1 bug.
Post by: sf-in-sf on 2012-Dec-13
Code (glbasic) Select

// --------------------------------- //
// Project: objtestA0
// Start: Thursday, November 29, 2012
// IDE Version: 10.244


// SETCURRENTDIR("Media") // go to media files
SETSCREEN 400,400,0
LIMITFPS 25
mymain() // call your own 'main Function' here.



//____________________________________
// quit GLb's main function like this:
FUNCTION foo:
// keep it empty.
ENDFUNCTION



//LOCAL z%
// this 'z' declaration doesn't work here any more,
// because it's outside a function.
INLINE

class Koto{
public:
int fish;
Koto(){}; // constructor
~Koto(){}; // destructor
void ppprint()
{ for (int z=3; z<=13; z++)
{ PRINT( z, 30+2*z,25*z);
PRINT( z+2, 60+2*z,25*z);
}

// F***
// // //ENDINLIN* // ADDING THE 'E' => ERROR.
// although it's printed in yellow like a comment.
// it's a 7-leg bug.
// INLINE ... is ignored properly.

/*
F***
other out-comments work o.k. otherwise.
*/

};
protected:
private: // ad libitum

};
ENDINLINE




FUNCTION mymain:
INLINE
Koto k; // instanciation.
k.ppprint(); // run the Fn.
ENDINLINE

SHOWSCREEN
MOUSEWAIT // please click to quit.
END

ENDFUNCTION // it works fine.

Title: Re: OOP quick tuto +1 bug.
Post by: Hemlos on 2012-Dec-14
interesting

im not too familliar with c++ classes and inheritance

how would you do something like this

FUNCTION mymain:
   INLINE
      Koto k; // instanciation.
      j=k;
      j.ppprint(); // run the Fn.
   ENDINLINE
Title: Re: OOP quick tuto +1 bug.
Post by: sf-in-sf on 2013-Jan-02
Normally, this doesn't copy the object. only the k reference gets copied. no j object is created. using j should act on the k object. Try and see.
Title: Re: OOP quick tuto +1 bug.
Post by: mentalthink on 2013-Jan-03
Very interesting I do the "clases" directly from GLbasic, but in C++ I think can be more powerfully... thanks because it's something I want learn from a long time ago... very very instructive...

Regards,