自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(42)
  • 收藏
  • 关注

原创 课堂作业

#include#includeusing namespace std;class Student {public: virtual void display(){}; string name; string number; Student *next; Student(); Student(const string &na, const string&no):

2015-06-02 06:20:35 337

原创 第四章 重载课堂作业

#include #include using namespace std; class Time { public: void display() { cout<<hour<<":"<<minute<<":"<<sec<<endl; } protected: int hour;

2015-05-19 17:56:01 358

原创 5.10

#include #include using namespace std;class Teacher {public: Teacher(int,char [],char); void display(); private: int

2015-05-19 17:32:56 315

原创 5.9

#include#includeusing namespace std;class Teacher{public: Teacher(string nam,int a,char s,string tit,string ad,string t); void display();protected: string name; int age; char

2015-05-18 23:41:50 291

原创 5.8

#include using namespace std;class A{public: A(){cout<<"constructing A "<<endl;} ~A(){cout<<"destructing A "<<endl;}};class B : public A{public: B(){cout<<"constructing B "<<endl;

2015-05-18 23:24:22 288

原创 5.7

#include using namespace std;class A{public: A(){a=0;b=0;} A(int i){a=i;b=0;} A(int i,int j){a=i;b=j;} void display(){cout<<"a="<<a<<" b="<<b;}private: int a; int b;

2015-05-18 23:19:12 287

原创 5.6

代码如下:#include using namespace std;class A{public: void f1( );protected: void f2();private: int i;};class B: public A{public: void f3( ); int k;private: int m;};cla

2015-05-18 23:11:57 279

原创 5.5

代码如下#includeusing namespace std;class A {public: void f1( ); int i;protected: void f2(); int j;private: int k;};class B: public A {public:

2015-05-18 22:52:02 292

原创 5.4

#include using namespace std;class Student{public: void get_value(); void display( );protected : int num; char name[10]; cha

2015-05-18 22:18:04 300

原创 5.3

#include using namespace std;class Student {public: void get_value(); void display( );protected : int num; char

2015-05-18 22:06:19 462

原创 5.2

#include using namespace std;class Student{public: void get_value() { cin>>num>>name>>sex; } void display( ) { cout<<"num: "<<num<<endl; cout<<"name: "<<name<<e

2015-05-18 21:58:00 260

原创 5.1

#include using namespace std;class Student{public: void get_value() { cin>>num>>name>>sex; } void display( ) { cout<<"num: "<<num<<endl; cout<<"name: "<

2015-05-18 21:47:41 250

原创 4.7

#include using namespace std;class Student{public: Student(int,char[],char,float); int get_num(){return num;} char * get_name(){return name;} char get_sex(){return sex;} void d

2015-04-26 13:27:15 211

原创 4.6

#include using namespace std;class Complex{public: Complex(){real=0;imag=0;} Complex(double r){real=r;imag=0;} Complex(double r,double i){real=r;imag=i;} operator double(){return real;

2015-04-26 13:17:09 295

原创 4.5

#include using namespace std;class Matrix{public: Matrix(); friend Matrix operator+(Matrix &,Matrix &); friend ostream& operator<<(ostream&,Matrix&); friend istream& operator>>(istream

2015-04-26 13:01:18 264

原创 4.4

#include using namespace std;class Matrix {public: Matrix(); friend Matrix operator+(Matrix &,Matrix &);

2015-04-26 12:49:26 365

原创 4.3

据题意, 要求不同类型的数据之间相加,且顺序任意,那么需要把运行符重载函数作为友元函数而不能作为成员函数#includeusing namespace std;class complex{public: complex(){real=1;imag=1;} complex(int r,int i){real=r;imag=i;} friend complex oper

2015-04-26 11:52:40 210

原创 4.2

#includeusing namespace std;class complex{public: complex(){real=0;imag=0;} complex(double r,double i){real=r;imag=i;} complex operator+(complex &c2); complex operator-(complex &c2

2015-04-26 11:40:28 280

原创 4.1

据题意,不用友元函数,且其为非成员函数, 那么, 运算符的重载则不能直接调用数据成员, 成员函数做为对外的链接口, 则需要在运算符重载中用到成员函数来调用数据成员#includeusing namespace std;class complex{public: complex(){real=0;imag=0;} complex(double r,double i){real

2015-04-26 11:00:22 446

原创 对类的认识

2015-04-20 23:00:11 329

原创 3.12

#include using namespace std;templateclass Compare{public: Compare(numtype a,numtype b); numtype max(); numtype min();private: numtype x,y;};template Compare::Compare(numtype

2015-04-20 16:07:06 230

原创 3.11

#include using namespace std;class Time;class Date{public: Date(int,int,int); friend Time;private: int month; int day; int year;};Date::Date(int m,int d,int y):month(m),da

2015-04-20 16:00:05 236

原创 3.10

#include using namespace std;class Date;class Time{public: Time(int,int,int); friend void display(const Date &,const Time &);private: int hour; int minute; int sec;};Time:

2015-04-20 15:55:45 525

原创 3.9

#include using namespace std;class Product{public: Product(int n,int q,float p):num(n),quantity(q),price(p){}; void total(); static float average(); static void display();private:

2015-04-20 15:42:38 262

原创 3.8

#include using namespace std;class Student{public: Student(int n,float s):num(n),score(s){} void change(int n,float s) {num=n;score=s;} void display() {cout<<num<<" "<<score<<endl;}pr

2015-04-20 15:23:40 393

原创 3.67

3.6 的图为:7:(1)把第2行改为const Student stud(101.78.5)后,表明其为常对象,只能调用它的常成员函数,而不能调用它的普通成员函数,即chang函数不能使用,把display函数申明为常函数, 则可以用。#include using namespace std;class Student{public: Student(i

2015-04-20 15:17:29 609

原创 3.5

#include using namespace std;class Student{public: Student(int n,int s):num(n),score(s){} void max(); private: int num; int score;};void Student::max(Student *p){ int m

2015-04-20 14:23:54 289

原创 3.4

#include using namespace std;class Student {public: Student(int n,int s):num(n),score(s){} void display(); private: int num; int score; };void Student::display(){ cout<<"学号

2015-04-20 09:16:13 232

原创 3.3

#includeclass Date{public: Date(int=1,int=1,int=2005); void display();private: int month; int day; int year;};Date::Date(int m,int d,int y):month(m),day(d),year(y){}void Dat

2015-04-19 22:44:00 267

原创 3.1 2

构造函数的作用:用于新建对象的初始化工作。 析构函数的作用:用于在撤销对象前,完成一些清理工作,比如释放内存。 每当创建对象时,需要添加初始化代码时,则需要定义自己的构造函数;而对象撤销时,需要自己添加清理工作的代码时,则需要定义自己的析构函数。#includeclass Date{public: Date(int,int,int); Date(int,int);

2015-04-19 22:39:07 410

原创 2.6

#includeusing namespace std;class V{private: int length; int width; int hight;public: void shuru(); void tiji();};void V::shuru(){ cin>>length; cin>>width; cin>

2015-04-15 18:10:45 251

原创 2.5

由于看错了2.4的例题,所以用2,.2的题目来进行改写多文件程序,请见谅//arraymax.husing namespace std;class Time{private: int hour; int minute; int sec;public: void set_time(); void show_time();};//file.cpp(

2015-04-15 17:41:02 261

原创 2.3

#include using namespace std;class Time {public: void set_time(void); void show_time(void); private: int hour; int minute; int sec; };void Time::set_time(void) {cin>>h

2015-04-15 17:21:21 243

原创 2.2

#include using namespace std;class Time {public: void set_time(void) {cin>>hour; cin>>minute; cin>>sec; } void show_time(void) {cout<<hour<<":"<<minute<<":"<<sec

2015-04-15 17:16:39 244

原创 1.14

#include #include using namespace std;template void sort(T a[]) {int i,j,min; T t; for(i=0;i<5;i++) {min=i; for (j=i+1;j<5;j++) if(a[min]>a[j]) min=j; t=a[i]; a[

2015-04-15 17:13:51 260

原创 1.13

#include #include using namespace std;int main(){ long c[5]={10100,-123567, 1198783,-165654, 3456}; int a[5]={1,9,0,23,-45}; float b[5]={2.4, 7.6, 5.5, 6.6, -2.3 }; void sort(int []);vo

2015-04-15 17:10:47 242

原创 1.12

#include #include using namespace std;int main(){ int i; string str[5]={"weixinhua","is","da","shuaige","nice"}; void sort(string []); sort(str); cout<<"the sorted strings :"<<endl; for(

2015-04-15 17:03:59 325

原创 1.11

#includeusing namespace std;#includeint main(){ char a[50]; cout<<"请输入一个字符串:"; cin>>a; int k=0; k=strlen(a); cout<<"Reverse order:"; for(;k>=0;k--) { cout<<

2015-04-15 16:57:50 286

原创 1.10

#includeusing namespace std;#includevoid main(){ string string1="weixinhua"; string string2=" is a shuaige"; string1=string1+string2; cout<<string1<<endl;}

2015-04-15 16:52:46 246

原创 1.9

#includeusing namespace std;void paixu(int &x, int &y,int &z){ int temp; if(x>y) {temp=y;y=x;x=temp;}; if(x>z) {temp=z;z=x;x=temp;}; if(y>z) {temp=y;y=z;z=temp;};}void

2015-04-15 16:48:06 321

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除