[Tutor] A new comer

Sean 'Shaleh' Perry shalehperry@attbi.com
Fri, 08 Mar 2002 10:25:46 -0800 (PST)


> 
> Then work through the tutorial that comes with the 
> documentation. As a C++ programmer you should have few 
> problems bar a slight culture shift as you get used 
> to dynamic typing and heterogenous collections.
> Oh yes and no public/private/protected sections 
> - don't worry its not as dangerous as you might think! 
> 

the other big thing that catches people is in C++ the variable *this is
implicit and you almost never see it.  Python requires you to use the variable
to do most of the class work (it is called 'self' in python).

class Foo:
  def __init__(self): # constructor
    self.bar = 0

  def getBar(self):
    return self.bar

f = Foo()
print f.getBar()

as you can see, self is a needed part of class access.

class Foo {
public:
  Foo(void): bar(0) {}

  int getBar(void) const { return bar; }

private:
  int bar;
};

Foo f;
cout << f.getBar() << '\n';