第一个C++

输入:cin>>(相当于scanf)
 
#include <iostream>
using namespace std;
int main()
{ int number;
 cout<<"hello!world!"<<endl; //printf "hello!world"
 cout<<"请输入数字:";
 cin>>number;   //输入数字
 cout<<"hello"<<number<<"lll"<<endl;  //输出hello+number里面的东西
 
 return 0;
}
 
 
面向对象:what is an object?
object=entity
#可见的(visible)
对象就是变量(object is variable in programming languges)
 
另一个角度:对象=结构;+服务(objects=attributes+services)
from the problem space to the solution 
 
C语言板的3d 图形效果
typedef struct point3d
{
float x;
float y;
float z;
 
 
} point3d;
 
void point3d_printf(const Point3d*pd);
point3d a;
a.x=1;a.y=2;a.z=3;
point3d_printf(&a);
 
 
 
C++板的
class point3d      //class=struct
{
public:
    Point3d(float x,float y,float z);
    print();   //调用print函数
private:
    float x;
    float y;
    float z;   //私有数据
};
 
point3d a(1,2,3);
a.print();     //a是一个对象    让a去做print函数功能
 
区别:
C语言的struct里不能做操作
C++的类里面可以做数据的操作
 
 
what  is object)-oriented  //导向
1.it is a way 
2.designs                    //设计  算法
3.implementations   //实现  写代码
4. object 主要用是设计与实现
 
 
 
 
面向对象的基本原理
object send messages
 
messages are 
-composed by the sender    //有发送z
-interpreted by the receiver //服务器快来解读
-implemented by methods   //y以函数的方式来传递
 
messges 
    may cause receiver to change state
    may return results 
 
 
object vs.class
类是一个概念
对象是一个实体
{class define object 
object is a class}
 
 
  object (cat)
    represent things events,or concepts
    respond to messages at run-time
 
类定义了对象章什么样    
对象是一个那样的东西
 
oop characteristics
1 everything is an obect .
2 a program is a bouch of objects telling eachoather what to do by sending messages.
3 each oject has its own memory made up of other objects.
4 every object has a type .   //每一个对象都是一个类
5 all object of a particular type can recieve the same messages .  //所有可以接受相同消息的对象可以被认为是同一个类
 
an object has an interface 
the  interface is the way it recevies messages.
it is 
 
functions of the interface //接口的功能
 
 
caommunication   //用于通信  里面的东西和外界的通信 
 protection  // 接口可以保护里面的东西 
 
 
the hidden implementation  //隐藏 封装的
 
oop的三特性
encapsulation   //封装  包装 
    bundle data and methods dealoing with thses data together in an object  //把数据和对数据的操作捆绑在一个对象里
    hide the details of the data the action   //里面的细节部分是隐藏的
     restrict(限制 约束) only access to the publicized  //只能看到公开的部分
bun
继承 
多态性
 
 
 

原文链接: https://www.cnblogs.com/da-guang/p/4140628.html

欢迎关注

微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍

    第一个C++

原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/156687

非原创文章文中已经注明原地址,如有侵权,联系删除

关注公众号【高性能架构探索】,第一时间获取最新文章

转载文章受原作者版权保护。转载请注明原作者出处!

(0)
上一篇 2023年2月11日 下午4:57
下一篇 2023年2月11日 下午5:04

相关推荐