大一C++学习日记
文章平均质量分 61
记录作业中遇到的问题
ItsNorth
学生罢了
展开
-
期末复习笔记(大一下)
大一下期末复习一些总结。主要内容关于类继承,多态,文件处理,异常处理和类模板。原创 2022-06-23 19:37:53 · 348 阅读 · 0 评论 -
自定义类模板的简单实践
T1:题目要求:Use an int template nontype parameter numberOfElements and a type parameter elementType to help create a template for the Array class. This template will enable Array objects to be instantiated with a specified number of elements of a spec原创 2022-05-24 21:35:13 · 180 阅读 · 0 评论 -
C++ 学籍管理系统的简单实现
仅为大家提供思路能跑,但似乎不太对,有时间改如果有问题希望能帮我指出目录题目要求:代码实现:源.cpp:Student.h:Student.cpp:题目要求:Create a simple random-access file-processing program that might be used by professors to help manage their student records. For each student, the progra原创 2022-05-08 17:22:29 · 638 阅读 · 0 评论 -
C++ 文件处理的简单应用(模拟从各种客户端访问一个网站)
#include<iostream>#include<fstream>#include<iomanip>#include<windows.h>#include<ctime>#include"Client.h"using namespace std;int cnt[5];void getData(fstream &x)//随机生成一组数据{ int a, b, c, d, f, g, h, i, j; a = rand.原创 2022-05-08 16:04:06 · 492 阅读 · 0 评论 -
C++ 银行账户的多态继承层次结构
目录Account.hAccount.cppexit(0):表示正常运行程序并退出程序SavingsAccount.hSavingsAccount.cppCheckingAccount.hCheckingAccount.cpp主函数:dynamic_castd的使用:详见博客Account.h#ifndef ACCOUNT_H#define ACCOUNT_Hclass Account{public: enum AccountType { ac..原创 2022-05-04 18:11:52 · 1814 阅读 · 0 评论 -
C++ 类继承的简单例子与理解
1.构造函数与析构函数调用顺序无其它类对象时:#include<iostream>using namespace std;class MyBase1{public: MyBase1() { cout << "…BaseClass1 Object is created!" << endl; }//1 ~MyBase1() { cout << "…BaseClass1 Object is destroyed!" << endl;原创 2022-04-20 13:24:41 · 857 阅读 · 0 评论 -
C++ RationalNumber有理数类的实现
完整版代码主函数#include<iostream>#include"RationalNumber.h"#include"GCDandLCM.h"using namespace std;int main(){ RationalNumber c(7, 3), d(3, 9), x; c.printRational(); cout << " + "; d.printRational(); cout << " = "; x = c + d; //原创 2022-04-12 16:21:31 · 911 阅读 · 0 评论 -
C++ HugeInt大整数类(高精度板子)
完整版源代码源.cpp#include <iostream>#include "Hugeint.h"using namespace std;int main(){ HugeInt n1(7654321); HugeInt n2(7891234); HugeInt n3("99999999999999999999999999999"); HugeInt n4("1"); HugeInt n5("12341234"); HugeInt原创 2022-04-11 14:16:14 · 1588 阅读 · 0 评论 -
C++ MyString类的实现
功能要求:功能1.0初步实现MyString类(数据属性包括char*list,intlength(字符串长度))1.1. 实现构造函数(通过字符串初始化list)1.2. 析构函数1.3. 字符串拼接1.4. 字符串比较大小(实现strcmp功能)1.5. 子串查找1.6. 提取某个位置字符1.7. 输出。功能2.02.1. 流输入>>和流输出<<运算符的重载2.2. 重载 = 运算符2.3. 重载 += 运算符2...原创 2022-04-07 08:28:09 · 2439 阅读 · 0 评论 -
#define宏定义浅学
目录1. 宏是在预处理指令#define中定义的一种操作.2.条件编译1. 宏是在预处理指令#define中定义的一种操作.(1)格式:#define <宏名/标识符> <字符串>例如:#define PI 3.14159(2)常见易错点 谁让你不加括号的,傻了吧#include<bits/stdc++.h>#define circle_area(x) (3*x*x)using namespace std;int ma..原创 2022-03-01 17:05:16 · 196 阅读 · 0 评论 -
超int爆负
int a=1,b=1;cout<<a*b;结果为1将a,b换为11,111,1111,11111...结果分别为121,12321,1234321....据此规律,当a,b值为111111时,结果应当为123454321但是输出结果却为 -539247567出现这种现象的原因就是超出了int的数据范围:int(整型)的数据范围:-2147483648——2147483647;计算机储存数据时会将十进制转化为二进制,而计算机储存系统又用...原创 2022-02-28 10:32:56 · 908 阅读 · 0 评论 -
测试函数运行时间
头文件:#include< ctime >clock()是C/C++中的计时函数,函数返回从“开启这个程序进程”到“程序中调用clock()函数”时之间的CPU时钟计时单元(clock tick)数CLOCKS_PER_SEC表示一秒钟内CPU运行的时钟周期数(时钟计时单元)...原创 2022-02-20 20:23:57 · 361 阅读 · 0 评论