[Matroska-devel] LibMatroska example question
steve.lhomme at free.fr
Wed Jan 25 19:00:12 CET 2006
Using global variables is usually a bad idea, even if that's the easiest
case. Your program won't be thread-safe and reentrant. In C++ you
usually offer a method in your class to give access to this variable, like :
KaxTracks & GetTracks();
const KaxTracks & GetTracks() const;
& will give you a reference to the object. That's like a pointer, but
you don't have to check if it's NULL. If you are not sure about this
syntax, just use pointers...
I hope it helped.
Armin Müller wrote:
> i write a multiplexing module for our multimedia framework at university.
> So i took the example code for multiplexing from the libmatroska package
> I have a class-method that does the multiplexing., this is where I call
> KaxTracks & MyTracks = GetChild<KaxTracks>(FileSegment); /* Filesegment
> is a KaxSegment */
> now I need to have the variable MyTracks globally in my class available,
> so I have to declare it outside of this function.
> I tried:
> KaxTracks MyTracks;
> &MyTracks = GetChild<KaxTracks>(FileSegment);
> I also tried it without ampersand, but I don't understand this syntax.
> Can anyone show me how to declare the variable (globally) and then
> assign the return value of GetChild?
> thanks and regards,
> Matroska-devel mailing list
> Matroska-devel at lists.matroska.org
> Read Matroska-Devel on GMane:
robUx4 on blog <http://robux4.blogspot.com/>
More information about the Matroska-devel