Answer the question
In order to leave comments, you need to log in
Qt syntax question?
Hello, please explain, there are lines of the form:
QLabel *label = new QLabel("Hello");
label->show();
I understand that [* label] is a pointer to the address of objects which will be many in the future, probably? But why is the name of the class and the string ["Hello"] there at once?
Let's say this is an example:
SomeClass a; //an object is created here based on the class
SomeClass *p = &a; //this is a pointer to the address of the object to // call class methods through it
p-> print("Hi")
Answer the question
In order to leave comments, you need to log in
QLabel *label = new QLabel("Привет");
The pointer is assigned the address of a new type object QLabel
with the text - "Hello" SomeClass *p
pointer to a type variableSomeClass
This is a C++ syntax question)
QLabel *label = new QLabel("Hi");
label->show();
QLabel("Hi")and returns a pointer to an address on the heap. Our object is located at this address
label->show();- we refer to the object through the POINTER to this object
SomeClass a; //an object is created here based on the class
SomeClass *p = &a; //this is a pointer to the address of the object to // call class methods through it
SomeClass a;and
new QLabel("Hi");that the object a exists on the stack, and QLabel("Hello"); in a heap
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question