C++
爱敲代码的小赤佬
自律和节制是一切幸福的开始!
展开
-
友元函数的引用
dispaly函数为普通函数(非类中),分别在Time,Date类中将display声明为友元函数,在主函数中调用dispaly函数,dispaly函数分别引用Time,Date中的私有数据成员,完成输出。#include <iostream>#include <stdio.h.>#include <stdlib.h>using namespace st...原创 2019-04-03 18:22:38 · 3093 阅读 · 0 评论 -
友元类练习
将Time声明为Date类的友元类,通过Time类中的display函数引用Date类对象中的私有数据,输出年月日,时分秒。#include <iostream>#include <stdio.h.>#include <stdlib.h>using namespace std;class Time;class Date{public: D...原创 2019-04-03 17:43:14 · 233 阅读 · 0 评论 -
c++实现对数据和常数据以及常函数的定义
#include <stdio.h>using namespace std;class st{public: st(int a,int b,int c); void display()const;private: int a1,b1; const int c1;};void st::display()const{ cout<...原创 2019-03-27 15:20:01 · 364 阅读 · 0 评论 -
C,C++中转义字符的用法
这里是引用\a 响铃(BEL) 007\b 退格(BS) 008\f 换页(FF) 012\n 换行(LF) 010\r 回车(CR) 013 :将当前位置移到本行开头,会将前面的内容按字节覆盖。\t 水平制表(HT) 009 :跳到下一个tab键的位置。\v 垂直制表(VT) 011\ 反斜杠 092’ 单引号字符 039" 双引号字符 034\0 空字符(NULL...原创 2019-02-27 16:29:40 · 1447 阅读 · 0 评论 -
普通函数被类引用为友元函数
#include <iostream>#include <stdio.h>#include <stdlib.h>using namespace std;class Date;class Time{public: Time(int ,int,int ); friend void display(Date &,Time &...原创 2019-04-17 18:23:21 · 304 阅读 · 0 评论 -
静态成员函数与静态数据的使用
#include <stdio.h>#include <stdlib.h>#include<math.h>#include <string.h>using namespace std;class mm{public: mm(){num=0;quantity=0;price=0;} mm(int a,int b,int c...原创 2019-04-17 23:26:33 · 150 阅读 · 0 评论 -
指针输出数组
定义一个对象数组,包含五个学生信息(学号,成绩),定义一个指针指向数组首元素,一次输出1,3,5学生的信息。using namespace std;class Student{public: Student(int a,int b) { num=a; grade=b; } void display() { cout...原创 2019-05-30 20:52:31 · 1634 阅读 · 0 评论