C++ Qt - disposal of a Class



  • I know the question is nuba, but still. I didn't work with Qt.

    Some participatory operations QTextStream

    Then I try to remove it through delete and the compiler makes a mistake. I'm looking at methods, and I don't find anything like methods. closeDispose(this is C#).

    So how do we remove copies of such objects? I don't want to hear the leak.

    Text of error:

    mistake: C2440: delete: It's impossible to convert "QTextStream" into "void*." There is no available change operator as defined by the user or a operator ' s challenge to achieve this change.

    QTextStream qtin(stdin);
    QString input = qtin.readLine();
    delete qtin;
    


  • Copies QString is built on the glass and is local. It'll be removed automatically when it's out of sight.

    I recall that the area of visibility of the variable is a block. {} where it is declared. Exclusion is global variables, i.e. variables declared outside the text. However, the quality design of the annex expressly prohibits any global variables.

    Your third line delete qtin; I just don't need it.

    Your approval is "no leak." There is a glass. The glass here refers to the area of memory of the annex where all local variables fall. It is organized as glass, with hardware support, at the level of the instructions of the processor.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2