64,643
社区成员
发帖
与我相关
我的任务
分享
QBrush();
QBrush(Qt::BrushStyle style);
QBrush(const QColor & color, Qt::BrushStyle style = Qt::SolidPattern);
QBrush(Qt::GlobalColor color, Qt::BrushStyle style = Qt::SolidPattern);
QBrush(const QColor & color, const QPixmap & pixmap);
QBrush(Qt::GlobalColor color, const QPixmap & pixmap);
QBrush(const QPixmap & pixmap);
QBrush(const QImage & image);
QBrush(const QBrush & other);
QBrush(const QGradient & gradient);
QBrush & operator=(const QBrush & brush);
QBrush & operator=(QBrush && other);
QBrush brush = Qt::blue;
qDebug() << brush;
#include<iostream>
using namespace std;
class A{
public:
A(int a){
cout<<"A(int a)"<<endl;
}
A(const A&){
cout<<"A(const A&)"<<endl;
}
private:
A& operator=(const A&){
}
};
int main()
{
A a(1); //直接显示调用A(int)
A b(A(1)); //先显示调用A(int),再显式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A c = A(1); //先显示调用A(int),再隐式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A d = 1; //先隐示调用A(int),再隐式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
return 0;
}
#include<iostream>
using namespace std;
class A{
public:
explicit A(int a){ //必须显示调用
cout<<"A(int a)"<<endl;
}
A(const A&){
cout<<"A(const A&)"<<endl;
}
private:
A& operator=(const A&){
}
};
int main()
{
A a(1); //直接显示调用A(int)
A b(A(1)); //先显示调用A(int),再显式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A c = A(1); //先显示调用A(int),再隐式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A d = 1; //1个错误
return 0;
}
#include<iostream>
using namespace std;
class A{
public:
A(int a){
cout<<"A(int a)"<<endl;
}
explicit A(const A&){ //必须显示调用
cout<<"A(const A&)"<<endl;
}
private:
A& operator=(const A&){
}
};
int main()
{
A a(1); //直接显示调用A(int)
A b(A(1)); //先显示调用A(int),再显式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A c = A(1); //1个错误
A d = 1; //1个错误
return 0;
}
#include<iostream>
using namespace std;
class A{
public:
explicit A(int a){ //必须显示调用
cout<<"A(int a)"<<endl;
}
explicit A(const A&){ //必须显示调用
cout<<"A(const A&)"<<endl;
}
private:
A& operator=(const A&){
}
};
int main()
{
A a(1); //直接显示调用A(int)
A b(A(1)); //先显示调用A(int),再显式调用A(const A&),编译器优化省略掉A(const A&)的调用,最后只调用A(int)
A c = A(1); //1个错误
A d = 1; //2个错误
return 0;
}
#include<iostream>
using namespace std;
class MyClass
{
public:
MyClass(int i) {
data = i;
}
//MyClass(int i) :data(i) {}
private:
int data;
};
int main() {
MyClass my = 1;
return 0;
}