Код: Выделить всё
zProc = new QProcess(this);
zProc->execute(cWgetLine);
Модератор: Fastman
Код: Выделить всё
zProc = new QProcess(this);
zProc->execute(cWgetLine);
Можно конечно, но:100kg писал(а):а что будет если мы неявно обратимся тоесть zProc.execute(cWgetLine)? заметил что явное обращение происходит когда динамически создаем объекты.Код: Выделить всё
zProc = new QProcess(this); zProc->execute(cWgetLine);
Код: Выделить всё
#include <iostream>
#include <new>
using std::cout;
using std::cin;
using std::endl;
class Test {
public:
Test (int = 0, int = 0);
~Test();
void setX(int);
void setY(int);
int getX();
int getY();
void printall();
private:
int x;
int y;
};
Test::Test(int Xvalue, int Yvalue )
{
setX(Xvalue);
setY(Yvalue);
}
void Test::setX(int Xvalue) {
x=Xvalue;
}
void Test::setY(int Yvalue) {
y=Yvalue;
}
int Test::getX() {
return x;
}
int Test::getY() {
return y;
}
void Test::printall() {
cout << "X value is: " << getX() << endl
<< "Y value is: " << getY() << endl;
}
int main () {
Test *t1ptr;
t1ptr = new Test(3,4);
/*must be t1ptr->printall(); or (*t1ptr).printall();
t1ptr.printall(); gives error */
t1ptr->printall();
return 0;
}
Код: Выделить всё
test.cpp:70: error: request for member `printall' in `t1ptr', which is of non-class type `Test*'
Код: Выделить всё
Test *t1ptr;
t1ptr = new Test(3,4);
Код: Выделить всё
Test t1ptr(3,4);
t1ptr.printall();
Код: Выделить всё
void SomeOtherClass::foo()
{
Test t1ptr(3,4);
t1ptr.printall();
//при выходе t1ptr будет уничтожен
}
Код: Выделить всё
class SomeOtherClass
{
SomeOtherClass();
~SomeOtherClass();
void foo();
void foo2();
Test *t1ptr;
}
SomeOtherClass::SomeOtherClass()
{
t1ptr = new Test(3,4);
}
void SomeOtherClass::foo()
{
//можем тут напечатать твои значения
t1ptr->printall();
}
void SomeOtherClass::foo2()
{
//и тут можем напечатать твои значения
t1ptr->printall();
}
//И !!! Не забываем сделать !!!!
SomeOtherClass::~SomeOtherClass()
{
if(t1ptr != NULL)
delete t1ptr;
}