Qt复习提纲

2026/4/27 19:05:34

void SetPositionY(int iPositionY) {

m_iPositionY = iPositionY; } private:

int m_iPositionX; // X坐标 int m_iPositionY; // Y坐标 };

int main(void) {

CPosition oPostion1;

const CPosition oPostion2(6, 8);

cout << oPostion1.GetPositionX() << endl; oPostion1.SetPositionX(16);

cout << oPostion1.GetPositionX() << endl; oPostion1.SetPositionY(18);

cout << oPostion1.GetPositionY() << endl; cout << oPostion2.GetPositionX() << endl; cout << oPostion2.GetPositionY() << endl; return 0; }

上面程序的输出结果为: 参考答案: 0 16 18 6 8

2.阅读下面程序,写出输出结果。 #include using namespace std; template class CTest {

public:

CTest(Type m_tArray[], int iSize):m_pArray(m_tArray) {

m_iSize = iSize; }

void Print() const {

for (int i = 0; i < m_iSize; i++)

{

cout << m_pArray[i] << \ } } private:

Type *m_pArray; int m_iSize; };

int main(void) {

int a[] = {1, 0, 8};

double b[] = {1.6, 1.8}; CTest oTest1(a, 3); oTest1.Print();

CTest oTest2(b, sizeof(b) / sizeof(double)); oTest2.Print(); cout << endl; return 0; }

上面程序的输出结果为:

参考答案:1 0 8 1.6 1.8

3.阅读下面程序,写出输出结果。 #include using namespace std; class CGoods {

public:

CGoods(int iWeight) {

m_iWeight = iWeight;

m_iTotalWeight = m_iTotalWeight + iWeight; }

CGoods(const CGoods &oGood) {

m_iWeight = oGood.m_iWeight;

m_iTotalWeight = m_iTotalWeight + m_iWeight; }

~CGoods() {

m_iTotalWeight = m_iTotalWeight - m_iWeight; }

void Print() const;

static int GetTotalWeight() {

return m_iTotalWeight; } private:

int m_iWeight;

static int m_iTotalWeight; };

int CGoods::m_iTotalWeight = 8; // 初始化静态数据成员 void CGoods::Print() const {

cout << this->m_iWeight << \}

int main(void) {

CGoods oGood1(6);

oGood1.Print(); CGoods oGood2(oGood1); oGood2.Print();

cout << CGoods::GetTotalWeight(); cout << endl; return 0; }

上面程序的输出结果为:

参考答案:6 14 6 20 20


Qt复习提纲.doc 将本文的Word文档下载到电脑
搜索更多关于: Qt复习提纲 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219