事件驱动复习3

Generally, data members should be declared private and member functions should be declared public.

set functions also called mutators
get functions also called accessors
classes often provide public member functions to allow clients of the class to set or get private data members.

Initializing objects with constructors:
(constructors are declared public)
1.Function: Each class can provide a constructors that can be used to initialize an object of the class when the object is created.
2.Define: A constructor is a special member function that must be defined with the same name as the class, so that the compiler can distinguish it from the class’s other member functions.
3.Difference between constructors and other functions : constructors cannot return value

A default constructors -that is, a constructor with no parameters (默认构造函数无参)

在这里插入图片描述

默认构造函数有两种产生方式:(1)编译器创建 (2)自己写(无参)
头文件 " "先找本地的class < >先找库

function prototype (函数名+返回类型+参数类型)
such as: void display( string );

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值