Incompatible type conversion

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jewel87
    New Member
    • Jan 2007
    • 62

    Incompatible type conversion

    Hello everyone,

    I'm working on a function reading data from file.
    I am getting an error: E2110 Incompatible type conversion
    Here is what i have:

    function in the form:
    Code:
    void __fastcall TForm1::EnterProductFromFileClick(TObject *Sender)
    {
            char ProductName[256]="";
            int ProductID;
            float Weight;
            char WeightCategory[256]="";
            float PriceWithoutVAT;
            float PriceWithVAT;
            char ExpiryDate[256]="";
            int AmountInStock;
            int ReorderLimit;
            char ProductCategory[256]="";
            char InputDate[256]="";
            char DueDate[256]="";
            char Manufacturer[256]="";
            char ManufacturerAddress[256]="";
            char OriginCountry[256]="";
    
            myProductList.getFoodProduct(i)->
    ReadDataFromFile(ProductName, ProductID, Weight, WeightCategory,
                                       PriceWithoutVAT, PriceWithVAT, ExpiryDate,
                             AmountInStock, ReorderLimit, ProductCategory,
    InputDate, DueDate, Manufacturer, ManufacturerAddress,OriginCountry); 
                        //error in the last line
    The function itself in class Food:
    Code:
    void Food :: ReadDataFromFile(char *ProductName,int &ProductID, 
                                      float &Weight, char *WeightCategory,
                                       float &PriceWithoutVAT, float &PriceWithVAT, 
                                      char *ExpiryDate, int &AmountInStock,
                                      int &ReorderLimit, char *ProductCategory,
                                       char *InputDate, char *DueDate,char *Manufacturer,
                                       char *ManufacturerAddress, char *OriginCountry)
    {
            ifstream inputfile;
            inputfile.open("input.txt");
    
             char check[256]="";
    
                 while(inputfile>>check)
                  {
                         inputfile>>ProductID;
                         inputfile>>ProductName;
                         inputfile>>Weight;
                         inputfile>>WeightCategory;
                         inputfile>>ExpiryDate;
                         inputfile>>PriceWithoutVAT;
    
                         PriceWithVAT = CalculateVATPrice(PriceWithoutVAT);
    
                         inputfile>>AmountInStock;
                         inputfile>>ReorderLimit;
                         inputfile>>ProductCategory;
                         inputfile>>InputDate;
                         inputfile>>DueDate;
                         inputfile>>Manufacturer;
                         inputfile>>ManufacturerAddress;
                         inputfile>>OriginCountry;
    
                    };
            inputfile.close();
    
    }
    What is wrong here???
  • tavianator
    New Member
    • Dec 2006
    • 38

    #2
    I would suggest using a structure or a class to store information about the product, rather than reams of individual variables. Simply pass an instance of this struct or class by non-const reference to the function which reads the data from the file, or better yet, make that function a member function of the new class.

    Comment

    • jewel87
      New Member
      • Jan 2007
      • 62

      #3
      Originally posted by tavianator
      I would suggest using a structure or a class to store information about the product, rather than reams of individual variables. Simply pass an instance of this struct or class by non-const reference to the function which reads the data from the file, or better yet, make that function a member function of the new class.
      I am using classes, and this function is a member of class. I have some problem with function call, why does it say Incompatible type conversion??

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        Originally posted by jewel87
        why does it say Incompatible type conversion??
        The error should say what argument is causing the problem. Maybe you could post the error.

        Comment

        • jewel87
          New Member
          • Jan 2007
          • 62

          #5
          Originally posted by weaknessforcats
          The error should say what argument is causing the problem. Maybe you could post the error.
          There is the problem, it is not saying anything about any types at all, just as it is here:
          E2110: Incompatible type conversion

          Comment

          • weaknessforcats
            Recognized Expert Expert
            • Mar 2007
            • 9214

            #6
            Then I have no idea. I can't even see the line number where the error was to have occurred.

            Comment

            Working...