【上海大学《面向对象程序设计A》课程小项目报告】抽象向量类模板及其派生类
1 项目内容及要求
本项目通过设计一个抽象向量类模板,以及一个通用的向量类模板和一个字符串类作为其派生类,以满足各种应用场景中的数据存储和处理需求。
项目内容:
- 抽象向量类模板。
- 派生向量类。
- 派生字符串类。
- 测试及异常处理。
- 联合测试
2.1 抽象向量类模板
2.1.1 数据成员设计
int num;//向量的维度
T* p;//存储元素的数组
2.1.2 成员函数设计
VECTOR(int size = 0, const T* x = NULL)//构造函数
VECTOR(const VECTOR& v)//拷贝构造函数
virtual ~VECTOR()//虚析构函数
VECTOR& operator=(const VECTOR& v)//赋值运算符重载
T& operator[](int index)//用于访问特定位置的元素
void resize(int size)//重设容器大小
virtual void Output(ostream& out) const = 0;//纯虚函数
virtual void Input(istream& in) = 0;//纯虚函数
2.2 派生向量类模板
2.2.1 定义纯虚函数
void Output(ostream& out) const
{if (__super::num == 0) out << "( )";else{out << "(" << __super::p[0];for (int i = 1; i < __super::num; i++){out << "," << __super::p[i];}out << ")" << endl;}
}void Input(istream& in)
{char c;T x;__super::resize(0);in >> c;if (c != '(') return;while (in >> x){__super::resize(__super::num + 1);__super::p[__super::num - 1] = x;in >> c;if (c == ')') break;}
}
2.2.2 成员函数设计
Vector(int size = 0, const T* x = NULL)//构造函数
Vector operator+(const Vector& v)//+运算符重载
2.2.3 测试及异常处理
int TestVector()
{int a[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };double x[8];for (int i = 0; i < 8; i++)x[i] = sqrt(double(i));Vector<int> vi1(10, a), vi2(5, a + 5);Vector<double> vd1(8, x), vd2(3, x);cout << "原始数据:" << endl;cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "调整维数到5:" << endl;vi1.resize(5);vi2.resize(5);vd1.resize(5);vd2.resize(5);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n将数据写入文件 vector.txt 中..." << endl;ofstream outfile("vector.txt");outfile << vi1 << '\n'<< vi2 << vd1 << '\n' << vd2 << endl;outfile.close();cout << "\n清除对象的数据(即调整维数到0)..." << endl;vi1.resize(0);vi2.resize(0);vd1.resize(0);vd2.resize(0);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n从文件 vector.txt 中读取的数据:" << endl;ifstream infile("vector.txt");infile >> vi1 >> vi2 >> vd1 >> vd2;infile.close();cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\nvi1 + vi2 = " << vi1 + vi2<< "\nvd1 + vd2 = " << vd1 + vd2 << endl;cout << "\n异常处理测试" << endl;Vector<int> v;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;//如果格式错误,则抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}
运行结果:

2.3 派生字符串类
2.3.1 定义纯虚函数
void Output(ostream& out) const
{for (int i = 0; i < __super::num; i++){out << p[i];}
}void Input(istream& in)
{string temp;in >> temp;*this = temp.c_str();
}
2.3.2 成员函数设计
String(const char* x = "")//构造函数
String operator+(const String& s)//+运算符重载
2.3.3 测试及异常处理
int TestString()
{String str1 = "Hello", str2 = str1, str3;// 转换构造 拷贝构造 默认构造cout << "原始数据(双引号是另外添加的):" << endl;cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;str3 = str2; // 赋值运算str1 = "C++ program.";str2 = str3 + ", world!"; // 拼接运算cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n将数据写入文件 string.txt 中..." << endl;ofstream outfile("string.txt");outfile << str1 << '\n'<< str2 << '\n'<< str3 << endl;outfile.close();cout << "\n清除对象的数据(即调整长度到0)..." << endl;str1.resize(0);str2.resize(0);str3.resize(0);cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n从文件 string.txt 中读取的数据:" << endl;ifstream infile("string.txt");infile >> str1>> str2>> str3;infile.close();cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n异常处理测试" << endl;String str4 = "Hello";try{cout << str4 << endl;cout << str4[10] << endl;//越界访问,抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}
运行结果:

3 联合测试
#include "Vec.h"int TestVector(), TestString(), Test();void menu()
{cout << "\n1 --- testing Vector [v]"<< "\n2 --- testing String [s]"<< "\n3 --- testing Vector & String [m]"<< "\n0 --- exit [q]"<< endl;
}int main()
{char choice = '0';do{menu();cin >> choice;switch (choice){case '1':case 'v':case 'V': TestVector(); break;case '2':case 's':case 'S': TestString(); break;case '3':case 'm':case 'M': Test(); break;case '0':case 'q':case 'Q':case 27: choice = 0; break;default: cout << "选择错误,重新选择" << endl; break;}} while (choice);return 0;
}int Test()
{Vector<int> v;String str;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;}catch (const char* str) { cout << str << endl;return 0;}cout << v << endl;cin.sync(); // 刷新输入流缓冲区(目的是读取并丢弃向量后的换行符)cout << "请输入一个字符串。如 abc 12345 xyz" << endl;cin >> str;cout << str << endl;cout << "\n将数据写入文件 output.txt 中..." << endl;ofstream outfile("output.txt");outfile << v << endl<< str << endl;outfile.close();cout << "\n清除对象的数据..." << endl;v.resize(0);str.resize(0);cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;cout << "\n从文件 output.txt 中读取的数据:" << endl;ifstream infile("output.txt");infile >> v;infile >> str;infile.close();cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;return 0;
}
运行结果:

4 完整代码
4.1 Vec.h
#pragma once
#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <fstream>
#include <string>
using namespace std;template <typename T> class VECTOR
{
public:VECTOR(int size = 0, const T* x = NULL){num = (size > 0) ? size : 0;p = NULL;if (num > 0){p = new T[num];for (int i = 0; i < num; i++)p[i] = (x == NULL) ? 0 : x[i];}}VECTOR(const VECTOR& v){num = v.num;p = NULL;if (num > 0){p = new T[num];for (int i = 0; i < num; i++)p[i] = v.p[i];}}virtual ~VECTOR(){if (p != NULL) delete[] p;}VECTOR& operator=(const VECTOR& v){if (num != v.num){if (p != NULL) delete[] p;p = new T[num = v.num];}for (int i = 0; i < num; i++)p[i] = v.p[i];return *this;}T& operator[](int index){if (index >= num) throw "越界访问";else return p[index];}void resize(int size){if (size < 0 || size == num) return;else if (size == 0){if (p != NULL) delete[] p;num = 0;p = NULL;}else{T* temp = p;p = new T[size];for (int i = 0; i < size; i++)p[i] = (i < num) ? temp[i] : 0;num = size;delete[] temp;}}virtual void Output(ostream& out) const = 0;virtual void Input(istream& in) = 0;int num;//向量的维度T* p;//存储元素的数组
};template <typename T> ostream& operator<<(ostream& out, const VECTOR<T>& v)
{v.Output(out);return out;
}template <typename T> istream& operator>>(istream& in, VECTOR<T>& v)
{v.Input(in);return in;
}template <typename T> class Vector :public VECTOR<T>
{
public:Vector(int size = 0, const T* x = NULL) :VECTOR<T>(size, x) {}void Output(ostream& out) const{if (__super::num == 0) out << "( )";else{out << "(" << __super::p[0];for (int i = 1; i < __super::num; i++){out << "," << __super::p[i];}out << ")" << endl;}}void Input(istream& in){char c;T x;__super::resize(0);in >> c;if (c != '(') throw "格式错误";while (in >> x){__super::resize(__super::num + 1);__super::p[__super::num - 1] = x;in >> c;if (c == ')') break;}}Vector operator+(const Vector& v){Vector Add;if (__super::num == v.__super::num){Add.resize(__super::num);for (int i = 0; i < __super::num; i++){Add[i] = __super::p[i] + v.__super::p[i];}}return Add;}};class String : public VECTOR<char>
{
public:String(const char* x = "") : VECTOR<char>(strlen(x), x) { }void Output(ostream& out) const{for (int i = 0; i < __super::num; i++){out << p[i];}}void Input(istream& in){string temp;in >> temp;*this = temp.c_str();}String operator+(const String& s){int i, j;String add;add.__super::num = __super::num + s.__super::num;add.p = new char[add.__super::num];for (i = 0; i < __super::num; i++){add.p[i] = p[i];}for (j = 0; j < s.__super::num; j++){add.p[i + j] = s.p[j];}return add;}};
4.2 Test.cpp
#include "Vec.h"int TestVector(), TestString(), Test();void menu()
{cout << "\n1 --- testing Vector [v]"<< "\n2 --- testing String [s]"<< "\n3 --- testing Vector & String [m]"<< "\n0 --- exit [q]"<< endl;
}int main()
{char choice = '0';do{menu();cin >> choice;switch (choice){case '1':case 'v':case 'V': TestVector(); break;case '2':case 's':case 'S': TestString(); break;case '3':case 'm':case 'M': Test(); break;case '0':case 'q':case 'Q':case 27: choice = 0; break;default: cout << "选择错误,重新选择" << endl; break;}} while (choice);return 0;
}int Test()
{Vector<int> v;String str;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;}catch (const char* str) { cout << str << endl;return 0;}cout << v << endl;cin.sync(); // 刷新输入流缓冲区(目的是读取并丢弃向量后的换行符)cout << "请输入一个字符串。如 abc 12345 xyz" << endl;cin >> str;cout << str << endl;cout << "\n将数据写入文件 output.txt 中..." << endl;ofstream outfile("output.txt");outfile << v << endl<< str << endl;outfile.close();cout << "\n清除对象的数据..." << endl;v.resize(0);str.resize(0);cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;cout << "\n从文件 output.txt 中读取的数据:" << endl;ifstream infile("output.txt");infile >> v;infile >> str;infile.close();cout << "向量:" << v << endl<< "字符串:\"" << str << "\"" << endl;return 0;
}
4.3 TestString.cpp
#include "Vec.h"int TestString()
{String str1 = "Hello", str2 = str1, str3;// 转换构造 拷贝构造 默认构造cout << "原始数据(双引号是另外添加的):" << endl;cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;str3 = str2; // 赋值运算str1 = "C++ program.";str2 = str3 + ", world!"; // 拼接运算cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n将数据写入文件 string.txt 中..." << endl;ofstream outfile("string.txt");outfile << str1 << '\n'<< str2 << '\n'<< str3 << endl;outfile.close();cout << "\n清除对象的数据(即调整长度到0)..." << endl;str1.resize(0);str2.resize(0);str3.resize(0);cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n从文件 string.txt 中读取的数据:" << endl;ifstream infile("string.txt");infile >> str1>> str2>> str3;infile.close();cout << "str1 = \"" << str1<< "\"\nstr2 = \"" << str2<< "\"\nstr3 = \"" << str3 << "\"" << endl;cout << "\n异常处理测试" << endl;String str4 = "Hello";try{cout << str4 << endl;cout << str4[10] << endl;//越界访问,抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}
4.4 TestVector.cpp
#include "Vec.h"int TestVector()
{int a[10] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };double x[8];for (int i = 0; i < 8; i++)x[i] = sqrt(double(i));Vector<int> vi1(10, a), vi2(5, a + 5);Vector<double> vd1(8, x), vd2(3, x);cout << "原始数据:" << endl;cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "调整维数到5:" << endl;vi1.resize(5);vi2.resize(5);vd1.resize(5);vd2.resize(5);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n将数据写入文件 vector.txt 中..." << endl;ofstream outfile("vector.txt");outfile << vi1 << '\n'<< vi2 << vd1 << '\n' << vd2 << endl;outfile.close();cout << "\n清除对象的数据(即调整维数到0)..." << endl;vi1.resize(0);vi2.resize(0);vd1.resize(0);vd2.resize(0);cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\n从文件 vector.txt 中读取的数据:" << endl;ifstream infile("vector.txt");infile >> vi1 >> vi2 >> vd1 >> vd2;infile.close();cout << "vi1 = " << vi1 << "\nvi2 = " << vi2<< "\nvd1 = " << vd1 << "\nvd2 = " << vd2 << endl;cout << "\nvi1 + vi2 = " << vi1 + vi2<< "\nvd1 + vd2 = " << vd1 + vd2 << endl;cout << "\n异常处理测试" << endl;Vector<int> v;cout << "请输入一个整数向量。如 (1, 3, 5, 7)" << endl;try{cin >> v;//如果格式错误,则抛出异常}catch (const char* str){cout << str << endl;return 0;}return 0;
}
注意:
包含项目的文件夹中以下三个文本文档需要自行创建:

相关文章:
【上海大学《面向对象程序设计A》课程小项目报告】抽象向量类模板及其派生类
1 项目内容及要求 本项目通过设计一个抽象向量类模板,以及一个通用的向量类模板和一个字符串类作为其派生类,以满足各种应用场景中的数据存储和处理需求。 项目内容: 抽象向量类模板。派生向量类。派生字符串类。测试及异常处理。联合测试…...
Leetcode每日一题学习训练——Python3版(到达首都的最少油耗)
版本说明 当前版本号[20231205]。 版本修改说明20231205初版 目录 文章目录 版本说明目录到达首都的最少油耗理解题目代码思路参考代码 原题可以点击此 2477. 到达首都的最少油耗 前去练习。 到达首都的最少油耗 给你一棵 n 个节点的树(一个无向、连通、无环…...
Java面试题(每天10题)-------连载(42)
目录 Spring篇 1、Spring Bean的作用域之间有什么区别? 2、什么是Spring inner beans? 3、Spring框架中的单例Beans是线程安全的吗? 4、请举例说明如何在Spring中诸如一个Java Collection? 5、如何向Spring Bean中诸如一个J…...
netty websocket学习
【硬核】肝了一月的Netty知识点 超详细Netty入门,看这篇就够了! bzm_netty_sb netty-chat vuewebsokect实现实时聊天,可单聊、可群聊(一) vue实现聊天栏定位到最底部(超简单、可直接复制使用)…...
【数据结构】环形队列
环形队列 1. 定义 环形队列就是将队列在逻辑上看作环形结构、物理上仍是数组形式存储的一种数据结构。 其实现主要分为两种情况: 浪费空间法记录空间法 2. 实现 实现要考虑的是成员变量 2.1 记录空间法 使用used标识当前存储了多少元素,如果为空&a…...
嵌入式C编码规范
嵌入式C编码规范 编码规范,没有最好,只有最合适,有但不执行不如没有。 嵌入式C编码规范 https://mp.weixin.qq.com/s/z4u3YnF6vdQ1olsLeF-y_A 更多嵌入式信息请关注微信公众号【嵌入式系统】...
Golang 并发 — 流水线
并发模式 我们可以将流水线理解为一组由通道连接并由 goroutine 处理的阶段。每个阶段都被定义为执行特定的任务,并按顺序执行,下一个阶段在前一个阶段完成后开始执行。 流水线的另一个重要特性是,除了连接在一起,每个阶段都使用…...
Elasticsearch:什么是非结构化数据?
非结构化数据定义 非结构化数据是指未按照设计的模型或结构组织的数据。 非结构化数据通常被归类为定性数据,可以是人类或机器生成的。 非结构化数据是最丰富的可用数据类型,经过分析后,可用于指导业务决策并在许多其他用例中实现业务目标。…...
15:00的面试,15:06就出来了,问的问题过于变态了。。。
从小厂出来,没想到在另一家公司又寄了。 到这家公司开始上班,加班是每天必不可少的,看在钱给的比较多的份上,就不太计较了。没想到5月一纸通知,所有人不准加班,加班费不仅没有了,薪资还要降40%…...
Web自动化测试怎么做?Web网页测试全流程解析
1、功能测试 web网页测试中的功能测试,主要测试网页中的所有链接、数据库连接、用于在网页中提交或获取用户信息的表单、Cookie 测试等。 (1)查看所有链接: 测试从所有页面到被测特定域的传出链接。 测试所有内部链接。 测…...
MySQL数据库SQLSTATE[22007]: Invalid datetime format 日期类型不能为空值的解决办法
如果你的数据库是mysql, 如果你创建表或插入数据时遇到的BUG–它长这样: Invalid datetime format: 1292 Incorrect datetime value: ‘’ for column ‘xxx’ at row 1 或 1067 - Invalid default value for ‘xx’ 那么我将赐予你 两套剑法: &#…...
搬运工让你分分钟了解Web接口测试
01、什么是接口 百度说:接口泛指实体把自己提供给外界的一种抽象化物(可以为另一实体),用以由内部操作分离出外部沟通方法,使其能被内部修改而不影响外界其他实体与其交互的方式 上面这句有点抽象,网上的…...
作业12.5
1.定义一个基类 Animal,其中有一个虛函数perform(),用于在子类中实现不同的表演行为。 #include <iostream>using namespace std; class Animal { private:int weight; public:Animal(){}Animal(int weight):weight(weight){}virtual …...
leetCode 47. 全排列 II + 回溯算法 + 图解 + 笔记
给定一个可包含重复数字的序列 nums ,按任意顺序 返回所有不重复的全排列 示例 1: 输入:nums [1,1,2] 输出: [[1,1,2],[1,2,1],[2,1,1]] 示例 2: 输入:nums [1,2,3] 输出:[[1,2,3],[1,3,2…...
Maya 2024(3D建模、动画和渲染软件)
Maya 2024是一款非常强大的3D建模、动画和渲染软件,它提供了许多新功能和改进,以帮助建模师、动画师和渲染师更加高效地进行创作。 在建模方面,Maya 2024引入了Symmetry(对称)功能,可以在网格两侧生成均匀…...
C++作业5
完成沙发床的多继承(有指针成员) 代码: #include <iostream>using namespace std;class Bed { private:double *money; public:Bed(){cout << "Bed::无参构造函数" << endl;}Bed(double money):money(new doub…...
Go语言很难吗?为什么 Go 岗位这么少?
其实这个话题已经躺在我的 TODO 里很久了,近来很多社区的小伙伴都私下来交流,也有在朋友圈看吐槽 Go 上海的大会没什么人。还不如 Rust 大会,比较尴尬。 今天主要是从个人角度看看为什么 Go 岗位看起来近来很难的样子? 盘一下数…...
为什么要替换 Object.defineProperty?
目录 前言:为什么要替换 Object.defineProperty? 详解:为什么要替换 Object.defineProperty? 总结: 前言:为什么要替换 Object.defineProperty? JavaScript中的Object.defineProperty是一种…...
百马百担c语言编程
以下是一个百马百担问题的C语言编程实现: #include <stdio.h>int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); int a[n], b[m], c[k]; for (int i 0; i < n; i) { scanf("%d", &a[i]);…...
C++检测字符串中有效的括号个数
匹配一个字符串buf中,连续包换运算符reg的次数: #include <iostream>//return 返回匹配的字符个数 //buf, 要检测的字符串 //reg, 包含的连续运算符 int GetMatchCount(std::string& buf, std::string& reg) {int nMatchCount 0;if (reg.…...
【大模型RAG】拍照搜题技术架构速览:三层管道、两级检索、兜底大模型
摘要 拍照搜题系统采用“三层管道(多模态 OCR → 语义检索 → 答案渲染)、两级检索(倒排 BM25 向量 HNSW)并以大语言模型兜底”的整体框架: 多模态 OCR 层 将题目图片经过超分、去噪、倾斜校正后,分别用…...
7.4.分块查找
一.分块查找的算法思想: 1.实例: 以上述图片的顺序表为例, 该顺序表的数据元素从整体来看是乱序的,但如果把这些数据元素分成一块一块的小区间, 第一个区间[0,1]索引上的数据元素都是小于等于10的, 第二…...
python打卡day49
知识点回顾: 通道注意力模块复习空间注意力模块CBAM的定义 作业:尝试对今天的模型检查参数数目,并用tensorboard查看训练过程 import torch import torch.nn as nn# 定义通道注意力 class ChannelAttention(nn.Module):def __init__(self,…...
【Java学习笔记】Arrays类
Arrays 类 1. 导入包:import java.util.Arrays 2. 常用方法一览表 方法描述Arrays.toString()返回数组的字符串形式Arrays.sort()排序(自然排序和定制排序)Arrays.binarySearch()通过二分搜索法进行查找(前提:数组是…...
23-Oracle 23 ai 区块链表(Blockchain Table)
小伙伴有没有在金融强合规的领域中遇见,必须要保持数据不可变,管理员都无法修改和留痕的要求。比如医疗的电子病历中,影像检查检验结果不可篡改行的,药品追溯过程中数据只可插入无法删除的特性需求;登录日志、修改日志…...
汽车生产虚拟实训中的技能提升与生产优化
在制造业蓬勃发展的大背景下,虚拟教学实训宛如一颗璀璨的新星,正发挥着不可或缺且日益凸显的关键作用,源源不断地为企业的稳健前行与创新发展注入磅礴强大的动力。就以汽车制造企业这一极具代表性的行业主体为例,汽车生产线上各类…...
Golang dig框架与GraphQL的完美结合
将 Go 的 Dig 依赖注入框架与 GraphQL 结合使用,可以显著提升应用程序的可维护性、可测试性以及灵活性。 Dig 是一个强大的依赖注入容器,能够帮助开发者更好地管理复杂的依赖关系,而 GraphQL 则是一种用于 API 的查询语言,能够提…...
Ascend NPU上适配Step-Audio模型
1 概述 1.1 简述 Step-Audio 是业界首个集语音理解与生成控制一体化的产品级开源实时语音对话系统,支持多语言对话(如 中文,英文,日语),语音情感(如 开心,悲伤)&#x…...
LLMs 系列实操科普(1)
写在前面: 本期内容我们继续 Andrej Karpathy 的《How I use LLMs》讲座内容,原视频时长 ~130 分钟,以实操演示主流的一些 LLMs 的使用,由于涉及到实操,实际上并不适合以文字整理,但还是决定尽量整理一份笔…...
uniapp 字符包含的相关方法
在uniapp中,如果你想检查一个字符串是否包含另一个子字符串,你可以使用JavaScript中的includes()方法或者indexOf()方法。这两种方法都可以达到目的,但它们在处理方式和返回值上有所不同。 使用includes()方法 includes()方法用于判断一个字…...
