1、面向过程

int a = 10;

int b =5;

int c = a+b;

int r1 = 10;

int r2 = 5;

double c = r1*r1*3.14 - r2*r2*3.14

缺点:重用性差,扩展性差,可维护性差

2、面向对象

(1)对象:万物皆对象,对象是类实例化出来的东西

(2)类:由众多对象抽象出来的东西,里面包含成员变量,成员属性,成员方法

例子:(简单)管理学生信息的程序 研究的对象主要是  学生 程序中的类 学生的类 (学号  姓名  性别  年龄 住址  联系方式 )

         student(code,name,sex,age,address,lianxi)

class Student  //定义类 关键字class  后面跟类名
{
    string code;  //成员变量code
    string name; //成员变量 name
    bool sex; //成员变量 sex
    int age; //成员变量 age
    string address; //成员变量 address
    string lianxi; //成员变量 lianxi
}

//造对象
Student s = new Student();  //关键字 new ,对象的类型是类的名字
View Code

相关文章:

  • 2021-05-21
  • 2021-05-17
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-10-15
  • 2021-06-22
猜你喜欢
  • 2022-01-12
  • 2022-12-23
  • 2022-12-23
  • 2021-07-23
  • 2021-12-06
  • 2021-07-18
  • 2022-12-23
相关资源
相似解决方案