Subj : Re: Equivalent in c/c++ to a simple javascript obj.
To : netscape.public.mozilla.jseng
From : block111
Date : Sat Oct 23 2004 11:06 pm
> >
> >
> > By the above code, you have more or less the same as the following in
> C/C++:
> >
> > An object named 'myobj' is declared inherits 'obj_base' which has a
> property
What?!!? you mean an object named 'myobj' is an instance of class (or
in js-speak, function) obj_base? obj_base has no properties. It is a
function-constructor.
> > 'x' as varient, which have a default value of 11. Then a function 'func1'
> > is added which will display the value of 'x' in the object.
> >
> > Javascript have no concept of private or public, and all variables are not
> > typed, so you can't set anything regarding these properties.
It's written in clear english and it has this meaning:
function MyClass(){
this.x; //public member; <- PUBLIC
var y; //private member; <- PRIVATE
z; //static member; <- STATIC
}
do you need examples that show that?
My original question was completely different (I already know how to
new objects).
There is a built-in class Array in javascript. The code for
spidermonkey is written in C and therefore this class Array is
somewhere inside written in C. I was asking for a quick simple example
to declare a class (see MyClass above) and that's it/ (Without all
the settin/getting code - only the data structure shell)
Ps:
> > > PS. I could execute a few strings of js code to make such a class
> > > declared, but I would like to know what is the code to make it in
> > > c/c++.
(that's means, I know that I could preexecute a few lines of js for
every context to achieve what I need, but it's not the goal, i wanted
to know the C way)
> >
> > "__PPS__" ???
> > news:723debfe.0410201140.5688fe13@posting.google.com ???...
> > > Hi,
> > > could somebody post a simple c/c++ code (or explain in simple words
> > > which api needed) required to declare a js class, so that this class
> > > would be predeclared (like Array)
> > > for example simple js code:
> > > function MyClass(){
> > > this.x; //public member;
> > > var y; //private member;
> > > z; //static member;
> > > }
> > > What is the equivalent c/c++ code?
> > > basicly each of the members might be a function, object, int etc, but
> > > for a simple example int (JS_Int or whatever) is ok.
> > >
> > > PS. I could execute a few strings of js code to make such a class
> > > declared, but I would like to know what is the code to make it in
> > > c/c++.
> > >
> > >
> > > Thanks
> >
> >
.