网站首页 站内搜索

搜索结果

查询Tags标签: cout,共有 1241条记录
  • c++11 为什么使用ref,和引用的区别

    std::ref只是尝试模拟引用传递,并不能真正变成引用,在非模板情况下,std::ref根本没法实现引用传递,只有模板自动推导类型时,ref能用包装类型reference_wrapper来代替原本会被识别的值类型,而reference_wrapper能隐式转换为被引用的值的引用类型。 std::ref主要是考虑…

    2022/9/17 14:17:21 人评论 次浏览
  • c++静态for循环

    #include <iostream>// 通过递归实现 template <int Beg, int End> struct static_for {template <typename Fn>void operator()(const Fn& fn) const{if (Beg < End){fn(Beg);static_for<Beg+1, End>()(fn); // 最后一次,2个数相等了,…

    2022/9/14 14:16:15 人评论 次浏览
  • 27

    1 #include <iostream>2 #include <string>3 using namespace std;4 template <class T>5 T SumArray(6 T *p,T *q){7 T sum = *p;8 while(++ p != q)9 sum += *p; 10 return sum; 11 } 12 int main() { 13 string array[4] = { "Tom…

    2022/9/14 6:19:07 人评论 次浏览
  • 024:这是什么鬼delete

    1 #include <iostream> 2 using namespace std;3 class A 4 { 5 public:6 A() { }7 virtual ~A() { cout << "destructor A" << endl; } 8 }; 9 class B:public A { 10 public: 11 ~B() { cout << "destructor B&qu…

    2022/9/14 6:19:06 人评论 次浏览
  • 25

    1 #include <iostream>2 using namespace std;3 class A {4 private:5 int nVal;6 public:7 void Fun()8 { cout << "A::Fun" << endl; };9 virtual void Do() 10 { cout << "A::Do" << e…

    2022/9/14 6:19:05 人评论 次浏览
  • 年月日闰年平年判断

    #include <iostream>using namespace std;class date{ int Year, Month, Day;public: void SetYear(int year); void SetMonth(int month); void SetDay(int day); int isLeap(int year);//布尔判断闰年 int Check(int year, int month, int day)…

    2022/9/12 23:25:48 人评论 次浏览
  • C++STL笔记

    STL学习笔记参考文档:https://cplusplus.com/reference/ https://zh.cppreference.com/w/首页 https://docs.microsoft.com/en-us/cpp/standard-library/cpp-standard-library-reference?view=msvc-170 https://github.com/huihut/interview总体总结容器分类容器复合情况…

    2022/9/11 1:24:31 人评论 次浏览
  • C++面向对象-构造函数与析构函数

    以OOP实现一个顺序栈为例, 介绍构造函数与析构函数 #include <iostream> #include <iterator> using namespace std;/*构造函数和析构函数函数的名字和类名一样,没有返回值 */ class SeqStack {public://构造函数有参数,可重载SeqStack(int size = 10) {cout …

    2022/9/7 1:41:37 人评论 次浏览
  • C++随笔cout.precision(n)的作用

    是C++输出函数cout的一个格式控制函数,用以控制输出数据的精度(保留小数点后几位) ... cout.precision(n); ...用于控制小数输出位数,例如 a = 1.2345; cout.precision(2); cout<<a<<endl; //输出1.23

    2022/9/5 1:23:19 人评论 次浏览
  • asio使用例子

    阻塞调用# include<iostream> # include<boost/asio.hpp> # include<boost/date_time/posix_time/posix_time.hpp> using namespace std;int main() {cout << "One" << endl;boost::asio::io_service io;boost::asio::deadline_t…

    2022/9/3 23:26:27 人评论 次浏览
  • C++ 地形导航系统之确定峰点的位置

    #include <iostream> #include <string> #include <fstream> #define N 64bool isPeak(int grid[][N], int r, int c);int main() {int nrows, ncols;int map[N][N];string filename;ifstream file;cout << "请输入文件名:\n";cin >…

    2022/9/1 1:22:56 人评论 次浏览
  • C++之STL

    1 STL概论STL(标准模板库): STL的分类:容器,算法和迭代器。 STL提供了6大组件:容器,算法和迭代器,仿函数、适配器(配接器)、空间配置器。2 三大组件的初识 容器: #define _CRT_SECURE_NO_WARNINGS #include <iostream> using namespace std; #include <…

    2022/8/31 14:54:40 人评论 次浏览
  • C++学习笔记-day03

    1、嵌套循环2、跳转语句 continue不会使整个循环终止,break会跳出循环 //输出2,跳过了1 goto A; cout << 1 << endl; A: cout << 2 << endl;3、数组

    2022/8/31 14:23:21 人评论 次浏览
  • c++学习案例:猜数字游戏

    最近在学习C++,遇到了一个案例:猜数字游戏案例要求:系统生成一个范围在1-100的随机整数,用户有5次猜数字的机会,当用户猜的数字大于或小于生成的值时进行提示,5次没猜对则失败,猜对则成功;代码: #include <stdio.h> #include <iostream> #include &l…

    2022/8/29 14:23:28 人评论 次浏览
  • C++中的cout.setf(ios::fixed)是什么意思?

    问题描述:在阅读一段代码时,发现代码的最后一部分出现 ... cout.setf(ios::fixed); cout.setf(ios::showpoint); ...解决: cout.setf()是通过设置格式标志来控制cout输出格式 cout.setf(ios::fixed)表示用正常的记数方式来输出(与科学计数法相对应) coutsetf(ios::sh…

    2022/8/28 14:24:29 人评论 次浏览
共1241记录«上一页1234...83下一页»
扫一扫关注最新编程教程