Search code examples
axaptax++morph-x

Compiler throwing error as variable is not declared X++


I have the following piece of x++ code:

static void Datatypes_class_variable(Args _args)
{
    // Declare a class variable from the RentalInfo class
    RentalInfo   rentalInfo;
    ;
    // An object is created and referenced by the
    // class variable rentalInfo
    rentalInfo = new RentalInfo();
    // Call methods to set/get data to/from the object
    rentalInfo.setCar("BMW 320");
    info(strfmt("The car is a %1", rentalInfo.getCar()));
}

I don't understand why the compiler is throwing me the error:

The RentalInfo variable was not declared.

As you can see, the variable has been already declared at the beginning. Thank you!


Solution

  • The type RentalInfo does not exist as a class.

    That is why the error is in line 4 column 4.