Declaration of a Global Class instance does not work-it works inside a function

This is my first post ; please be gentle.
This works:

#include "amerLib.h"
//Gyro gyro;
void setup() {
}

void loop() {
	Gyro gyro;
	while(true) {
    gyro.readD(4);
    Serial.print ( gyro.readDt[0]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[1]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[2]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[3]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[4]);
    Serial.print("\t");
    Serial.println ( gyro.readDt[5]);
    delay(100) ;
  }
}

This does not:

#include "amerLib.h"
Gyro gyro;
void setup() {
}

void loop() {
	//Gyro gyro;
	while(true) {
    gyro.readD(4);
    Serial.print ( gyro.readDt[0]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[1]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[2]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[3]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[4]);
    Serial.print("\t");
    Serial.println ( gyro.readDt[5]);
    delay(100) ;
  }
}

The only difference is the Global declaration does not work whereas the declaration of Gyro in the loop function works fine. I need to have the global as it called in a lot of other functions in another app. If I try to call a function from loop which has an argument for the instance gyro - it works erratically i.e. it gives a few right values and then some totally erratic values.
Any help will be greatly appreciated.

This does not:

That's too lame for comment. The code does something. You have not described what it actually does.

Why are you using an infinite loop inside an infinite loop()?

To answer your second question first; I do not wish to recreate the instance of gyro everytime I loop in function loop.
The constructor Gyro() goes through a calibration process for the actual hardware gyro evertime it is called.
To answer your second question, here is the code for class Gyro:
Gyro.h

class Gyro :public MPU6050{
  private:
    bool  dmpReady;
    uint8_t mpuIntStatus;   // holds actual interrupt status byte from MPU
    uint8_t devStatus;      // return status after each device operation (0 = success, !0 = error)
    uint16_t packetSize;    // expected DMP packet size (default is 42 bytes)
    uint16_t fifoCount;     // count of all bytes currently in FIFO
    uint8_t fifoBuffer[64]; // FIFO storage buffer
    int16_t ax, ay, az;
    int16_t gx, gy, gz;
    // orientation/motion vars
    Quaternion q;           // [w, x, y, z]         quaternion container
    VectorInt16 aa;         // [x, y, z]            accel sensor measurements
    VectorInt16 aaReal;     // [x, y, z]            gravity-free accel sensor measurements
    VectorInt16 aaWorld;    // [x, y, z]            world-frame accel sensor measurements
    VectorFloat gravity;    // [x, y, z]            gravity vector
    float euler[3];         // [psi, theta, phi]    Euler angle container
    float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
 		void newtonR(int);
  protected:
    MPU6050 mpu;
  public:
    static bool mpuInterrupt ;
    float readDt [6];
    Gyro ();
    //void dmpDataReady();
    // yaw pitch roll
    //in=1 Quaternion, 2 Euler, 3 Realaccel, 4 world accel
    void readD (int);
    void calibrate();
};

I think the problem is being created by the statement MPU6050 mpu; in the protected: declarations. It does not make the slightest difference if I declare class Gyro a friend or child of class MPU6050. The inheritance statement on top is not necessary and it works without it also.
Thank you for being helpful - I have tried googling and reading a book on C++ but seem to be getting no where.

Sorry, but I do not want you overwhelm you with information. But below is a short write up on the class Gyro which I have given to my students whom I am trying to teach how to use the Arduino platform.

8 Gyro ( based on the GY?521 MPU6050 six axis sensor)
8.1 Basics
The gyro sensor we are using is a six axis sensor. It has an accelerometer built in
which measures acceleration along the three axii (x,y,z) in g’s. One g being 9,830
mm/sec2 . It also has a three axis gyroscope (gyro) which measures angular
velocity around the three axii; the units for this are deg/sec. For a more detailed
explanation please refer to:
http://www.instructables.com/id/Accelerometer?Gyro?Tutorial/?ALLSTEPS
The acceleration readings in a gyro are prone to noise. This noise needs to be
filtered out by using what is known as a low pass filter. This filter cuts out all
frequencies above a predefined level. In our particular case all frequencies above
48Hz are filtered out. It is still noisy and jerky and therefore calculating velocities
and distances, although, theoretically possible are a waste of time in these type of
low cost devices. Gyro readings are prone to drift and special techniques are
available to control this to a certain extent.
These type of gyros are also prone to offset (which vary from gyro to gyro) and
sensitivity errors. In our particular case sensitivity for acceleration has been set at
16384 and for the gyro at 131 and both assumed to be constant for all gyros. At
the time of declaring an instance for Gyro the class goes through a calibration
procedure which negates the offsets on all six axii. An interval halving technique is
used to achieve this.
At the time of starting it is critical that the gyro is absolutely still with its z axis
perpendicular to the ground plane and the x and y axii as you perceive them to
be.
This class is almost entirely based on the excellent work of J Rowberg and can be
found here:

The only difference being that it has been converted to a class and the calibration
method has been added.
8.2 Instance
Gyro anyName ;
For some reason which I fail to comprehend, the instance needs to be created in
the void loop() function as given in the example below. If you declare it globally it
does not seem to work. I am sure this will be sorted out in the near future.
8.3 Methods
readD( R );
Where R is an integer number between 0 and 6.
0 – returns the 6 raw values (after calibration) (ax,ay,az,gx,gy,gz)
1 – returns the raw values adjusted for sensitivity – so they are meaningful, in the
form ax,ay,az,gx,gy,gz.
2 – returns the quaternion values in the following form w,x,y,z.
3 – returns the Euler angles in the form x,y,z.
4 – returns the Yaw, Pitch, Roll in the form y,p,r.
5 – returns the real acceleration adjusted to remove gravity in the form x,y,z
6 – returns the world frame gravity adjusted to remove gravity in the form x,y,z.
8.4 Properties
readDt[];
where they will normally be interrogated as follows:
anyName.readDt[0], anyName.readDt[1), … up to anyNamereadDt[5]. These
return the appropriate values ( please see the example)
8.5 Examples
given the examples folder as “Gyro”

Since your class derives from MPU6050, the instance that is created IS a MPU6050. Having the instance contain another instance of the MPU6050 class does not make sense.

The constructor should just create the object and that's it.

Really? I thought that was the job of a default constructor. If you're not happy with the default initialization value for class members (e.g., zero or null), then you pass in values that you want the object to have for its members upon instantiation.

Whether the initialisation takes place inside the constructor or another function within the class I think is a matter of semantics with each person doing it in his/her own way. It is not the real issue.
The real problem is making the instance gyro global. As published in this post; the class definition contains :public MPU6050. However if you remove this inheritance it still works in the same way. I have also tried making MPU6050 a friend in Gyro and making a friend Gyro in MPU6050. Still works the same way i.e. inside the function loop and not when it is declared globally.
Cannot help feeling that the statement MPU6050 mpu; in the protected portion of class Gyro is the problem but I cannot seem to figure out how to fix it ...

Cannot help feeling that the statement MPU6050 mpu; in the protected portion of class Gyro is the problem but I cannot seem to figure out how to fix it ...

Delete it!

The way your class is defined a Gyro IS a MPU6050, so creating an instance of MPU6050 in the class is wrong.

Delta_G
you were two hundred per cent right and I was wrong. I wrote a small function to initialise everything (which I was previously doing in the constructor) which I call from setup and everything started working beautifully.
Thank you so very much for persevering on the call to init(), I finally saw the light.
Thank you once again I had been struggling with this for the last week.
The working code is given below:

#include "amerLib.h"
Gyro gyro;
void setup() {
	gyro.initialise();
}

void loop() {
	//Gyro gyro;
	while(true) {
    gyro.readD(4);
    Serial.print ( gyro.readDt[0]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[1]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[2]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[3]);
    Serial.print("\t");
    Serial.print ( gyro.readDt[4]);
    Serial.print("\t");
    Serial.println ( gyro.readDt[5]);
    delay(100) ;
  }
}

Why is there still an infinite loop in the infinite loop()?

There is of course no need for that now. I was just doing something quick and dirty. Here is the cleaned up code:

#include "amerLib.h"
Gyro gyro; // create the instance
void setup() {
  gyro.initialise(); // initialise the instance
}

void loop() {
  gyro.readD(4);
  Serial.print ( gyro.readDt[0]);
  Serial.print("\t");
  Serial.print ( gyro.readDt[1]);
  Serial.print("\t");
  Serial.print ( gyro.readDt[2]);
  Serial.print("\t");
  Serial.print ( gyro.readDt[3]);
  Serial.print("\t");
  Serial.print ( gyro.readDt[4]);
  Serial.print("\t");
  Serial.println ( gyro.readDt[5]);
  delay(100) ;
}