摘要: 转载自:http://blog.csdn.net/coder_xia/article/details/74478221、关于构造函数1)用构造函数确保初始化对于一个空类[cpp]view plaincopyclassEmpty{};编译器会自动声明4个默认函数:构造函数,拷贝构造函数,赋值函数,析构函数(当然,如果不想使用自动生成的函数,就应该明确拒绝),这些生成的函数都是public且inline。构造函数对数据成员进行初始化,使用未初始化值可能导致无法预知的错误,所以,确保每一个构造函数都将每一个成员初始化。2)为什么构造函数不能有返回值如果有返回值,要么编译器必须知道怎么处理返回值,要么 阅读全文
posted @ 2012-12-08 22:27 一把刷子 阅读(872) 评论(0) 推荐(0) 编辑
摘要: sizeof()是一个操作符,不是函数。#include<iostream>#include<stdio.h>#include<string.h>using namespace std;int main(){ int a=printf("a")<<endl; cout<<a<<endl; cout<<sizeof(printf("abc"))<<endl;} 阅读全文
posted @ 2012-12-08 22:18 一把刷子 阅读(120) 评论(0) 推荐(0) 编辑