C++中的类(firstly_see_you)

OOP(objective-oriented programming)

the definition of class and objectives

  1. objective is an item in the real world; such a student, a loan from the bank
  2. objective could be described as properties and actions, the first word of which could be characterized by data values and the second word of which could be told by functions.
  3. the properties of an objective could be described as follows:
    • abstraction
    • polymorphism(多态)
    • inheritance
    • encapsulation (封装)
  4. In programming language, objective is just like a kind of data type in generation way. For example, if you want a variable in int data type, we could use the int a to generate integer variable named a. There is a question what data type of objective is. The answer is class.
  5. How to generate a class is just like the way to generate the structure: class Peoples { doube height; double weight; int running(double distance){}}
  6. now we could construct the objective use Peoples sunny, hellen, jobs

how to create an objective and access its members

  1. you need to know a special function named Constructors function:
    • feature_1: automatic invocation(自动调用)
    • feature_2: has the same name as the defining class(与类本身同名)
    • feature_3: no return value(**including void **)
    • feature_4: can be overloaded
    • feature_5: could have no any argument
  2. a class may be declared without constructors
    • a no argument constructor with an empty body is simplicity declared in the class. (complier will help you to create the no argument constructor function automatically)
    • this constructor, called a default constructor is provided automatically only if no constructors are explicitly declared in the class.
  3. I will use the following example to illustrate the declaration of class and creation of its constructors; of course there is overloading function in creating the class.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值