I wrote the code, but it displays the following error:

C:\Works\contr_glsso1\mainwindow.cpp:771: ошибка: C2664: 'Line_Graph::Set_Data' : cannot convert parameter 2 from 'PTYPE *' to 'double *' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 

I do not know what to do. ; _;

defines.h

  typedef float PTYPE; 

struct.h

  PTYPE *RE; 

mainwindows.h

 void Update_Line(double X); 

mainwindows.cpp

 void MainWindow::Update_Line(prof->RE) // вот тут вот он выдает ошибку 

Tried to lead to type failed:

  void MainWindow::Update_Line((unsigned double *)prof->RE) // выдает ошибку C2664 

Here is another option:

  void MainWindow::Update_Line(*prof->RE) // выдает C2100: illegal indirection 

And further:

  double f1 = *prof->RE; void MainWindow::Update_Line(f1) // ошибка: C2109: subscript requires array or pointer type 

Even so I tried:

  double f1 = *prof->RE; void MainWindow::Update_Line(f1) // ошибка: C2109: subscript requires array or pointer type 

I can’t convert a PTYPE into a double, I can’t give up a variable - I use it a lot where I use it. The code is not mine, just ran into a problem.

  • The question here is not how to bring one to the other, but why do you need it. Update_Line expects a floating point number. And you give him a pointer to some mysterious PTYPE . - yrHeTaTeJlb
  • 2
    show the PTYPE implementation - yrHeTaTeJlb
  • Give at least a PTYPE announcement. In general, with such a question, even if you are told how to make the code compile , it is not a fact that it will work . For example, you can simply write Update_Line(0.0); :) - Harry
  • PTYPE implementation added - timob256
  • Tried: Update_Line(*prof->RE) ? - jfs

2 answers 2

Put the whole code:

  void MainWindow::Update_Line(prof->RE) // вот тут вот он выдает ошибку 

This line is suspicious, there should be something like:

  void MainWindow::Update_Line(double x); 

But in the place where you call it, some type conversions may be needed.

  • I have simplified the code quite a bit, leaving the essence, if I put all the people watching it will get confused, I would not want to. - timob256

With this implementation

 typedef float PTYPE; PTYPE *RE; 

RE is just a pointer to float , so it should work just

 Update_Line(*RE); 

But you told us exactly everything? Why, then, are you trying so hard to get prof->RE ? Maybe this field in the structure? need to bring all the information!

If this field is in the structure, and prof is a pointer to it, then it should work

 Update_Line(*prof->RE); 

If it does not work, give us additional information. What is RE , prof and so on.
You need the answer - so why do you have to drop information drop by drop? ... :(

And yet - the compiler's message about the function Line_Graph::Set_Data , and you diligently Update_Line . So where is the mistake?