class Neuron;
typedef vector<Neuron> Layer;
Neuron and Layer are both classes.
The original code is here.
class Neuron;
typedef vector<Neuron> Layer;
local Neuron
--#creating an object
obj = {}
obj.data = "this is a string"
function obj.m1(self, ...) --#here we use the self as lua won't set it for us, we could call it anything else. For compatibility the object is the first parameter
print(self.data) --#self.data is the same as obj.data as self is obj
end
function obj:m2(...) --#here we used a colon instead of a dot, this means that Lua will make the self variable for us. The object is the first parameter but Lua is adding that in for us
print(self.data)
end
--#calling object methods
--#both of the above methods do the same thing in nearly the same way (the colon is shorthand for us, and will be again)
obj.m1(obj) --#we used a dot so we have to pass the obj table so that the object knows what it is
obj:m1() --#this time we use a colon so lua is passing the table without us having to do so.
obj:m1(obj) --#we just passed obj twice (with lua doing it first), while this may not cause problems with the method, it probably is not what we want to do
obj.m2(obj)--#back to using dot just to prove that both calls work with both functions
obj:m2() --#colon works here too
Here is something that may make life easier and/or more confusing: http://pastebin.com/c5xqMUb9