第三章 c++ 面向对象程序设计

Click here to load reader

Upload: della

Post on 12-Jan-2016

124 views

Category:

Documents


9 download

DESCRIPTION

第三章 C++ 面向对象程序设计. 面向对象程序设计. 武汉大学 赵小红. 本章主要内容. 面向对象程序设计概述: object oriented programming, OOP OOP 思想、 OOP 基本特点 C++ 类: 类的定义与实现、内联成员函数、构造与析构、 this 指针、静态成员、友元等 类继承: 基类和派生类、多重继承、虚基类 多态性: 虚函数,重载,模板. 结构化程序设计方法. 重点: 如何实现细节过程,将数据与函数分开。 特点: 自顶向下,逐步求精 —— 功能分解。 形式: - PowerPoint PPT Presentation

TRANSCRIPT

PowerPoint Presentation





int NewS);
void ShowTime();



int NewS);
void ShowTime();


1. :
A B
2. :





CC++
C++C
void showTime(); //
{
minute=(m>=0 && m<60) ? m:0;
second=(s>=0 && s<60) ? s:0;
}
}

C++
C++
C++
:
chcount++;
}
word is %d\n",wdcount);
char is %d\n",chcount);
while((ch=getche())!='\r')
—C++
 
 
minute=(m>=0 && m<60) ? m:0;
second=(s>=0 && s<60) ? s:0;
}
}
};
Time *m_t2=new Time;

C++
cout<<"A"<<endl; }
~XYZ()

{
<<minute<<':'<<second<<endl;
<<minute<<':'<<second<<endl;
} // main()






cin>>radius;
//
}
Fencing Cost is 2858.85
Concrete Cost is 4335.39
void showTime();
{
}
}
<<this->second<<endl;
C++
{
<<"ID:"<<pObj->m_ID<<endl;
fun();

—C++
C++


—C++
—C++

C++


protected
private
void setPoint(int a, int b) { x=a; y=b; }; //
int getX() { return x; }; // X
int getY() { return y; }; // Y
};
{
int getRadius() { return radius; }; //
int getUpperLeftX() { return getX()radius; };
// X
// Y
main()
<<", Radius="<<c.getRadius()<<endl;
};
//

//
};
};
};
{
int radius;
public: //
{
{
int height;
public: //
{
// PointCircleCylinder
Cylinder constructor[400] [100] [200300]
Cylinder destructor[400] [100] [200300]
Circle destructor[100] [200300]
Point destructor[200300]
Line5: void SetMember(int m) {member=m;}
Line6: int GetMember() const {return member;}
Line7: private:
public:
strcpy(m_name,name);
strcpy(m_ID,ID);
strcpy(m_school,school);
strcpy(m_number,number);

}
// DBC
virtual
{
{
// DBC
{
{
{

}
};
void showA() {
void showB() {



CShape()“pShape->Draw()”pShape



virtual void Area()=0
protected:
};
};
ptr[0]=&s1;//
ptr[0]->SetValue(10,5);
ptr[0]->Area();//
ptr[0]->Disp();
int area(){ return 0; }
int area() {return u*w;}
private:
void main(){
Rect rct(2,4,10,6);
C++
}
}
}

Box(int ht, int wd, int dp) //
{ height=ht; width=wd; depth=dp; }
int Volume() { return height*width*depth; }
};
};
{
Complex complex;
}
Complex(float x=0, float y=0) { r=x; i=y; };
Complex operator+(Complex);
//
return temp;
Complex complex;
}
}

C++

C++
}

T1 Max( T1 x, T2 y)
{
}

}
}
// T
{
};
};
};
class MyTemClass
C++
class MyTemClass //
void ShowMax()
};
mt.ShowMax();