![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
北冥有鱼nkl
这个作者很懒,什么都没留下…
展开
-
000000组合_1
// Exercise 9.12 Solution: Point.h#ifndef POINT_H#define POINT_Hclass Point {public: Point( double = 0.0, double = 0.0 ); // default constructor // set and get functions void setX( double ); void setY( double ); double getX();原创 2021-12-19 14:48:30 · 166 阅读 · 0 评论 -
const/异常提示
#include "Rectangle.h"Rectangle::Rectangle(double tempLength, double tempWidth) //constructor{ setLength(tempLength); setWidth(tempWidth);}double Rectangle::calculatePerimeter() //calculate perimeter{ return 2*(length+width);}double Rec原创 2021-12-19 14:35:29 · 193 阅读 · 0 评论 -
C++/array_1
// Exercise 7.13 Solution: Ex07_13.cpp#include <iostream>#include <array>using namespace std;int main(){ /*1、常量变量:const 类型 变量名 = 某个具体值 2、常量变量必须在声明的时候被初始化:如const int a; a=10; 是错误的,const int 型变量不能被修改 3、正确的写法:const int a = 10;*/原创 2021-12-18 00:53:03 · 204 阅读 · 0 评论 -
C++/vector_1
// Exercise 7.14 Solution: Ex07_14.cpp#include <iostream>#include <vector>using namespace std;int main(){ const int SIZE = 20; // smallest possible size of vector /*1、vector对象的申明方式:vector<type>对象名 【所有缺省的元素都会被初始化为0,即未初始化的元素默认初原创 2021-12-18 00:25:04 · 71 阅读 · 0 评论 -
C++/Array类的实例
//头文件/Array.h/*Array.h*/#pragma once#ifndef ARRAY_H#define ARRAY_H#include <iostream>/**/class Array{ /*友元函数,重载流插入、流提取运算符*/ /*1、用户自定义的类型的数据,要使用流插入"<<"和流提取">>"必须进行重载 2、流插入,流提取只能重载为全局函数,不能重载为成员函数*/ /*1、重载为友元函数,参数的个数等于操作数个数;重载为原创 2021-11-30 00:16:12 · 810 阅读 · 0 评论 -
C++/析构函数/ 构造函数的调用方式
#include using namespace std;class Person{public:Person(){//无参构造函数(也叫默认构造)cout<<“person 的无参构造函数调用”<<endl;}Person(int a){//有参构造函数cout<<“person 的有参构造函数”<<endl;age = a;}//有参和无参构造都是普通构造//拷贝构造函数Person(const Person &p){//原创 2021-11-11 21:17:36 · 581 阅读 · 0 评论 -
C++/构造函数与析构函数
#include using namespace std;class Person{public:Person(){cout<<“person 的构造函数调用”<<endl;}~Person(){cout<<“person 的析构函数调用”<<endl;}};test1(){Person p; //栈上的对象,test1执行完后会释放p对象,从而掉用析构函数}int main(){test1();return 0;}1、原创 2021-11-09 17:10:13 · 513 阅读 · 0 评论 -
C++/多文件编程/类和对象/Circle和Point类举例
//main.cpp/*This program is to create a circle class and realize the functionof judging the position relationship between two circles*/#include #include “point.h”#include “circle.h”using namespace std;//class Point{//the class of point//public://原创 2021-11-06 22:21:49 · 343 阅读 · 0 评论 -
c++/类和对象
/*This program is to create a circle class and realize the functionof judging the position relationship between two circles*/#include using namespace std;class Point{//the class of pointpublic:int setX(int x){myX=x;}int setY(int y){myY=y;}int原创 2021-11-06 21:07:11 · 53 阅读 · 0 评论