
语言
pzzpztyy2009
不予置评
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
C++位域结构体举例
一种空间换时间的策略,输出结果第一行可能与编译器有关。#include <iostream>using namespace std;enum Level { FRESHMAN, SOPHOMORE, JUNIOR, SENIOR };enum Grade { A, B, C, D };class Student {public: Student(unsigned n...原创 2019-01-31 20:38:04 · 180 阅读 · 0 评论 -
c++示例代码-友元
一、友元函数#include <iostream.h>#include <math.h>class Point //Point类声明{ public: //外部接口 Point(int xx=0, int yy=0) {X=xx;Y=yy;} int GetX() {return X;} int GetY() {return Y;} friend flo...原创 2019-02-19 17:57:04 · 236 阅读 · 0 评论 -
c++示例代码-静态数据成员
#include <iostream>using namespace std;class Point {public: Point(int xx=0, int yy=0) {X=xx; Y=yy; countP++; } Point(Point &p); int GetX(){return X;} int GetY(){return Y;} ...原创 2019-02-18 19:13:04 · 216 阅读 · 0 评论 -
c++构造函数与拷贝构造函数,组合类构造函数
1、如果没有显示声明构造函数时,系统给生成构造函数,此时随机赋值,并不是0。若后面定义对象时有参数会报错。#include<iostream>using namespace std;class A{ private: int a; public: inline int get_a() { return a; }};...原创 2019-01-31 02:12:20 · 395 阅读 · 0 评论 -
c++输出问题,不得其解
一、输出为空#include<iostream>using namespace std;class A{ private: int a; public: A(int ap=5){ a=ap; } inline int get_a() { return a; }};int ma...原创 2019-01-31 01:58:23 · 198 阅读 · 0 评论 -
函数声明导致的潜在错误
C语言函数声明时可以不写省略不写 参数类型,但是这样可能会造成隐藏的错误。编译器未报错。#include<stdio.h>int ma(double a,double b);int main(){ int i=1; printf("%d",ma(2,3));}int ma(double a,double b){ return a+b;...原创 2019-01-30 17:31:05 · 280 阅读 · 0 评论 -
一文搞懂C语言的字法——转义字符
从大一接触C语言开始就对谭老师的书中的转义字符的出现搞得莫名其妙,经过几次思考现在将思考成果沉淀一下,如有错误还望指出。 一、文本首先要搞明白这里符号的构成文本一共分为两类:源程序文件以及输出数据结构。这些统统保存在内存中以ASC码的形式。 二、功能从符号的功能角度可以将符号分为:①文字符:包括10个数字、52个大小字母②运算符:③分隔符④空白符⑤...原创 2019-01-30 13:34:25 · 779 阅读 · 0 评论 -
C++ Primer plus第一章
原创 2019-01-30 00:54:44 · 146 阅读 · 0 评论 -
示例代码-----变量的生存期可见性作用域
#include<iostream.h>int i=1; // i 为全局变量,具有静态生存期。int main() { static int a;// 静态局部变量,有全局寿命,局部可见。 int b=-10; // b, c为局部变量,具有动态生存期。 int c=0; void other(void); cout<<"---MAIN---\...原创 2019-01-31 23:08:30 · 321 阅读 · 0 评论 -
构建者模式
class Person{ private String name; private String address; private int age; private int sex; private int height; private int weight; public void setName(String name) {thi...转载 2019-04-13 18:54:57 · 126 阅读 · 0 评论