Interfacing with Real World not Working in Classes Inside Classes

I have an Arduino Uno, rev 3 and am using IDE version 1.0.1. I am attempting to build a robot.
I wrote a class using class Servo (the one provided with Arduino) to synchronize the two drive motors, and it compiles. The problem is it doesn’t do anything else. Here is a test program for it, which should move the robot forward.

#include <Servo.h>

/******************************
 class to coordinate the two
 drive wheels of the robot.
 the wheels are represented by
 class Servo from Servo.h
******************************/

class Locomotion  {
  public:
    // pass constructor the pin numbers to be used
    Locomotion(int Lpin, int Rpin);
    
    // move one unit forward
    void moveForward();
    
    // turn in place to the left
    void turnLeft();
    
    // turn in place to the right
    void turnRight();
    
    // u-turn clockwise
    void uTurn();
    
  private:
    Servo Lservo, Rservo;
    const byte Lzero, Rzero; // the values that will stop the motors
    const byte maxSpeed; // the fastest a motor can go without exceeding another. The motors are reversed relative to each other in order to face the same way relative to the robot. So since their calibration is not exactly 90, ordering Lservo.write(180) and Rservo.write(0) would give the robot a slight veer
  };
    
//                        pin numbers for motors   precalculated values    this determines the fastest either motor can go (see above)
Locomotion::Locomotion(int Lpin, int Rpin) : Lzero(94), Rzero(95), maxSpeed((Lzero > 90 ? 180 - Lzero : Lzero) > (Rzero > 90 ? 180 - Rzero : Rzero) ? (Rzero > 90 ? 180 - Rzero : Rzero) : (Lzero > 90 ? 180 - Lzero : Lzero)) {
  Lservo.attach(Lpin); // init motors
  Rservo.attach(Rpin);
  
  pinMode(Lpin, OUTPUT);
  pinMode(Rpin, OUTPUT);
  }
  
// move one square forward
void Locomotion::moveForward()  {
  Lservo.write(90 + maxSpeed); // start
  Rservo.write(90 - maxSpeed);
  delay(1000);
  Lservo.write(Lzero); // ...and stop
  Rservo.write(Rzero);
  }
  
// turn in place to the left
void Locomotion::turnLeft()  {
  Lservo.write(90 - maxSpeed); // start
  Rservo.write(90 - maxSpeed);
  delay(1000);
  Lservo.write(Lzero); // ...and stop
  Rservo.write(Rzero);
  }
  
// turn in place to the right
void Locomotion::turnRight()  {
  Lservo.write(90 + maxSpeed); // start
  Rservo.write(90 + maxSpeed);
  delay(1000);
  Lservo.write(Lzero); // ...and stop
  Rservo.write(Rzero);
  }
  
// u-turn clockwise
void Locomotion::uTurn()  {
  turnRight();
  turnRight();
  }
  
Locomotion Wheels(3, 11);

void setup()  {}

void loop()  {
  Wheels.moveForward(); // go forward
  }

I know that I am generating the correct values for the motors to use because I ran that snippet of code in Dev-C++, got the numbers and used them to run the motors with two Servo classes and the motor went straight. So for some reason it just doesn’t work when contained in another class. I could not get around this by just using to servo classes because I would still want them in my class representing the robot. When I upload this code, the motors both spin full speed forward, meaning that the robot spins in a lopsided circle. This happens even if I remove Wheels.moveForward(); from the sketch. It also still occurs if void loop() is blank and I add

Lservo.write(Lzero);
Rservo.write(Rzero);

at the bottom of my constructor. I was having similar issues with a class for xbees http://arduino.cc/forum/index.php/topic,133903.msg1009551.html#msg1009551 and I think this is the same problem. Is there any way to get around this besides not using classes?
Thanks for any help you can give me.
-Gabriel

You cannot call arduino functions till setup() has been called.

  pinMode(Lpin, OUTPUT);
  pinMode(Rpin, OUTPUT);

empty your constructor ( leave init list ) add a begin or setup function to your class with the above in it, then call from the sketch setup()

do the servo init there too to be safe

You cannot call arduino functions till setup() has been called.

The init() function that sets up the hardware is called before setup(). So, technically, you can't call hardware-related functions until after init() is called. But, since setup() is called immediately after init() gets done, setup() is the first place where hardware-related calls are guaranteed to work.

Thank you. I had always wondered why arduino classes had functions that did what I thought should have been in the constructor

initializing variables is still safe though, right?

initializing variables is still safe though, right?

Yes.

Even not on the Arduino, doing substantive work in constructors can be problematic:

http://www.cs.technion.ac.il/users/yechiel/c%2B%2B-faq/static-init-order.html

Initializing simple variables should be safe, however. By simple variables I don't mean things that depend on other things being initialized (eg. the String class, or doing a malloc).

Setting a variable to zero, or initializing low-level types (eg. byte, int, long) should be fine.