uacs2024

导航

2024年3月27日 #

C++复制构造函数、=运算符重载

摘要: C++复制构造函数、=运算符重载 #include<iostream> using namespace std; class base{ private: int x,y; public: base():x(2),y(4) {cout << "base default constructor" << 阅读全文

posted @ 2024-03-27 13:02 ᶜʸᵃⁿ 阅读(1) 评论(0) 推荐(0) 编辑

2024年3月26日 #

C++文件类(文件流类)及用法详解

摘要: open() fstreamifstreamofstream 打开指定文件,使其与文件流对象相关联。 is_open() 检查指定文件是否已打开。 close() 关闭文件,切断和文件流对象的关联。 swap() 交换 2 个文件流对象。 operator>> fstreamifstream 重载 阅读全文

posted @ 2024-03-26 20:04 ᶜʸᵃⁿ 阅读(16) 评论(0) 推荐(0) 编辑

2024年3月24日 #

动态数组类及其模板

摘要: 先定义point类,再定义由point类的动态数组 #include <iostream> #include <cassert> using namespace std; class Point { private: int x, y; public: Point() : x(0), y(0) {c 阅读全文

posted @ 2024-03-24 18:58 ᶜʸᵃⁿ 阅读(11) 评论(0) 推荐(0) 编辑

2024年3月23日 #

复试C++看程序写结果 易错

摘要: 复试C++看程序写结果 易错 #include <iostream> using namespace std; void function(char *& s1, char *& s2){ int i = 0; for(; *s1 != *s2; s1++, s2++) i++; //当两个指针同时 阅读全文

posted @ 2024-03-23 17:19 ᶜʸᵃⁿ 阅读(6) 评论(0) 推荐(0) 编辑

2024年3月22日 #

C++看程序写结果:类继承与类组合,默认与含参的构造先后顺序 易错

摘要: C++类继承与类组合,默认与含参的构造先后顺序 易错 这道题原本是没有那么多输出信息的,是我自己加上了调用什么函数的提示。 一开始以为就输出两行,一行是构造父类时A:5,一行是构造子类时x=5,A::x=5。 #include "bits/stdc++.h" using namespace std; 阅读全文

posted @ 2024-03-22 17:55 ᶜʸᵃⁿ 阅读(4) 评论(0) 推荐(0) 编辑

复试C++19真题_看程序写结果_前置++运算符重载 易错

摘要: 考察前置++运算符设置为友元函数,这题的坑在于,返回值是不是对象的引用,形参也不是对象的引用,导致自增离开了作用域以后就不在有任何效果。 #include <iostream> using namespace std; class C{ private: int xx,yy; public: C(i 阅读全文

posted @ 2024-03-22 15:00 ᶜʸᵃⁿ 阅读(4) 评论(0) 推荐(0) 编辑

2024年3月21日 #

复试C++16真题_程序设计1_输出句子中每个单词长度

摘要: 输入一行文本,按照相应格式输出每个单词的长度 #include <iostream> using namespace std; #include <string> #include <vector> #include <iomanip> int main(){ string sen = " qwe 阅读全文

posted @ 2024-03-21 18:50 ᶜʸᵃⁿ 阅读(6) 评论(0) 推荐(0) 编辑

复试C++15真题_程序设计4_查找字符串并替换 ??

摘要: 复试C++15真题_程序设计4_查找字符串并替换 编写findRepStr函数,功能为在字符串str中寻找目的字符串findStr,并用replaceStr字符串替换,最后输出替换后的字符串str 我不知道可不可以用string,于是我用了字符数组,用暴力匹配寻找字符串。 #include <ios 阅读全文

posted @ 2024-03-21 17:23 ᶜʸᵃⁿ 阅读(7) 评论(0) 推荐(0) 编辑

2024年3月20日 #

复试C++15真题_程序设计2_递归_输入字符串倒序转整形

摘要: 编写一个递归函数,功能为:输入一个字符串,输出一个整数值。例如输入 "1a2xcz3 4 ,5a!6" , 输出654321。 一开始想不明白怎么写递归,于是我写了迭代的函数。意识到,递归的过程就是实现了迭代的循环,而循环内的操作本质没有太大差别。于是就写出来了: #include <iostrea 阅读全文

posted @ 2024-03-20 20:42 ᶜʸᵃⁿ 阅读(5) 评论(0) 推荐(0) 编辑

复试C++14真题 看程序写结果5 虚函数、继承 易错?

摘要: 复试C++14真题 看程序写结果5 虚函数、继承 #include <iostream> using namespace std; class A{ public: virtual void print() {cout<<"A::print"<<endl;} //void print() {cout 阅读全文

posted @ 2024-03-20 18:31 ᶜʸᵃⁿ 阅读(1) 评论(0) 推荐(0) 编辑