Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Are you 1337 enough

Name: Anonymous 2008-09-23 22:37

This code does not compile.
Only the 1337est h4x0rz know the fix.

Name: Anonymous 2008-09-23 22:37


class superclass
{
    float _x, _y;
public:
 
    void set(const float x, const float y)
    { _x = x;  _y = y; }
};


class childclass : public superclass
{
public:
    void set(int s) {}
};


int main()
{
    childclass kid;
 
    kid.set(1.f, 2.f);
    return 0;
}

Name: Anonymous 2008-09-23 22:43

In Haskell classnames must start with a Capital letter, and preferably use CamelCase.

Please keep that in mind and you will surely reach Komeji Satori without continuing.

Name: Anonymous 2008-09-23 23:03

using superclass::set;

Name: HMA 2008-09-23 23:54

>>1
The compiler will only look for functions with that name in the parent class if none has the same name in the derived class. It'll work if you call kid.superclass::set(1,2); or what >>4 posted, but then you already know that if you're posting the problem - unlike the fact that your anus has just been haxed.

Name: Anonymous 2008-09-24 0:04

zomfg haskell!!! O_O

Name: Anonymous 2008-09-24 0:42

Fixed it.

class SuperClass a where
  set :: a -> a -> ()

instance SuperClass (Float,Float) where
  set (x,y) = () where _x = x; _y = y

class ChildClass (SuperClass a) where
  set :: a -> ()

instance ChildClass Int where
  set s = ()

main = do kid::ChildClass Int
          set 1.0 2.0
          return ()

Name: Anonymous 2008-09-24 8:07

>>6-7
These should be inversed.

Name: Anonymous 2008-09-26 17:21


class Superclass():
    def __init__(self):
        self._x = 0.0
        self._y = 0.0
    def set(x,y):
        self._x = x
        self._y = y
class Childclass(Superclass):
    def update(x,y):
        super(Childclass,self).set(x,y)

kid = Childclass()

kid.set(1.0,2.0)

Name: Anonymous 2008-09-26 21:19

>>9
WTF?

class Superclass (object):
    def __init__(self):
        self.x = self.y = 0.

class Childclass (Superclass):
    pass

kid = Childclass()
kid.x, kid.y = 1., 2.


Noobs...

(Just in case you're wondering, this is what's wrong with >>9:
1. Old-style class
2. Could have used multiple assignment
3. What's that stupid setter for!? This is Python!
4. What's Childclass.update for?
5. Why the call to super?)

Name: Anonymous 2008-09-26 21:35

>>10
Why does Python have several ways of doing classes?

Name: Anonymous 2008-09-26 21:37

>>10
Doesn't know OOP

Name: Anonymous 2008-09-26 21:37

class Superclass
    attr :x, :y
    def initialize; @x = @y = 0; end
    def set x,y; @x, @y = x, y; end
end
class Childclass < Superclass
    def set x, y; end
end

Name: Anonymous 2008-09-26 21:39

>>2
Optimized lazy version:
main :: IO ()
main = return () -- do nothing

Name: Anonymous 2008-09-26 21:58

>>11
Because old classes are old, and new classes are new. Actually, they are not new; they have been there for years, and old classes are deprecated. The differences, though, are small.

>>12
No, you're the fag who doesn't know about properties and the essence of OOP. OOP is not "what C++ does" or "what Java does".

>>13
Putting bodies and ends in the same line won't make it look nicer, simpler or shorter.

Name: Anonymous 2010-11-14 16:03

Name: Anonymous 2011-02-03 0:31

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List