const

2. CMake 系列 - 编译多文件项目

依然范特西╮ 提交于 2020-04-04 17:00:45
目录 1. 编译不使用第三方库的项目 1.1 项目目录结构 1.2 相关代码 1.3 编译 2. 编译使用第三方库的项目 2.1 项目目录结构 2.2 相关代码 2.3 编译 1. 编译不使用第三方库的项目 1.1 项目目录结构 test/ ├── build ├── CMakeLists.txt └── src ├── include │ └── sub │ └── sub.h ├── init │ └── main.c └── sub └── sub.c 博主一般写项目都是以这种风格进行划分目录,这个风格也是参考内核风格。 build : 存放 cmake 生成的相关文件和make 编译生成的相关中间文件 CMakeLists.txt : 使用cmake 语法编写这个文件,cmake 负责将其转换为相对应makefile src : 存放源代码 include : 存放每个模块头文件,每个模块都有自己的目录; 1.2 相关代码 sub.h #ifndef _SUB_H #define _SUB_H int sub(const int a, const int b); #endif sub.c #include "sub/sub.h" int sub(const int a, const int b) { return a - b; } main.c #include "sub

C编译错误:Main.c:4:5: error: variably modified ‘f’ at file scope int f[maxn];

半腔热情 提交于 2020-04-04 13:49:42
错误范例:    #include<stdio.h> const int maxn=10000+10; int f[maxn]; int cnt; 错误原因: C中const不是指常量,而是表示只读;const声明常量是在C++中的用法 C中声明一个固定长度数组,可用:    #define MAXN 256 int f[MAXN]; 来源: https://www.cnblogs.com/debug-the-heart/p/12631175.html

HttpRuntime的认识与加深理解

给你一囗甜甜゛ 提交于 2020-04-04 08:30:40
下面最先介绍HttpRuntime的Web.config里的配置 < httpRuntime executionTimeout = " number " maxRequestLength = " number " requestLengthDiskThreshold = " number " useFullyQualifiedRedirectUrl = " [True|False] " minFreeThreads = " number " minLocalRequestFreeThreads = " number " appRequestQueueLimit = " number " enableKernelOutputCache = " [True|False] " enableVersionHeader = " [True|False] " apartmentThreading = " [True|False] " requireRootedSaveAsPath = " [True|False] " enable = " [True|False] " sendCacheControlHeader = " [True|False] " shutdownTimeout = " number " delayNotificationTimeout = " number "

const函数

谁说我不能喝 提交于 2020-04-04 08:23:50
const的函数不能对其数据成员进行修改操作。 const的对象,不能引用非const的成员函数。 // test1107.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include <iostream> using namespace std; class aa{ int num; public: aa(){ int b =10; num = b; }; void out1(){ cout<<num<<endl; } void out2() const{ cout<<num<<endl; } void out3() const{ num+=10; //出错,const函数不能修改其数据成员 cout<<num<<endl; } }; int _tmain(int argc, _TCHAR* argv[]) { aa a1; a1.out1(); a1.out2(); a1.out3(); const aa a2; a2.out1(); // 错误,const的成员 不能访问非const的函数 a2.out2(); a2.out3(); return 0; } 来源: https://www.cnblogs.com/raichen/p/5551562.html

Const,Const函数,Const变量,函数后面的Const (zz)

坚强是说给别人听的谎言 提交于 2020-04-04 08:23:04
看到const 关键字,C++程序员首先想到的可能是const 常量。这可不是良好的条件反射。如果只知道用const 定义常量,那么相当于把火药仅用于制作鞭炮。const 更大的魅力是它可以修饰函数的参数、返回值,甚至函数的定义体。 const 是constant 的缩写,“恒定不变”的意思。被const 修饰的东西都受到强制保护,可以预防意外的变动,能提高程序的健壮性。所以很多C++程序设计书籍建议:“Use const whenever you need”。 1.用const 修饰函数的参数 如果参数作输出用,不论它是什么数据类型,也不论它采用“指针传递”还是“引用传递”,都不能加const 修饰,否则该参数将失去输出功能。const 只能修饰输入参数: 如果输入参数采用“指针传递”,那么加const 修饰可以防止意外地改动该指针,起到保护作用。 例如StringCopy 函数: void StringCopy(char *strDestination, const char *strSource); 其中strSource 是输入参数,strDestination 是输出参数。给strSource 加上const修饰后, 如果函数体内的语句试图改动 strSource 的内容,编译器将指出错误。 如果输入参数采用“值传递”,由于函数将自动产生临时变量用于复制该参数

专题训练之拓步排序

↘锁芯ラ 提交于 2020-04-04 04:26:05
推荐几个博客:https://blog.csdn.net/dm_vincent/article/details/7714519 拓扑排序的原理及其实现 https://blog.csdn.net/u012860063/article/details/38017661 拓扑排序的几种写法 https://blog.csdn.net/shahdza/article/details/7779389 拓扑排序题集 1.基于DFS的拓扑排序:一般适用于数据较小并且需要判断有无环的情况 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int maxn=150; 6 int n,vis[maxn],topo[maxn],cnt; 7 bool g[maxn][maxn],flag; 8 9 void dfs(int u) 10 { 11 if ( vis[u]<0 ) { 12 flag=false; 13 return; 14 } 15 if ( vis[u]>0 ) return; 16 else vis[u]=-1; //表示当前还在访问中 17 for ( int v=1;flag&&v<=n;v++ ) { 18 if ( g[u][v] ) dfs

专题训练之强连通分量

北城余情 提交于 2020-04-04 04:23:18
tarjan模板 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int maxn=20010; 6 const int maxm=50010; 7 struct edge{ 8 int to,nxt; 9 }edge[maxm]; 10 int head[maxn],tot; 11 int low[maxn],dfn[maxn],stack[maxn],belong[maxn]; 12 int index,top; 13 int scc; 14 bool vis[maxn]; 15 int num[maxn]; 16 17 void addedge(int u,int v) 18 { 19 edge[tot].to=v; 20 edge[tot].nxt=head[u]; 21 head[u]=tot++; 22 } 23 24 void tarjan(int u) 25 { 26 int v; 27 low[u]=dfn[u]=++index; 28 stack[top++]=u; 29 vis[u]=true; 30 for ( int i=head[u];i!=-1;i=edge[i].nxt ) { 31 v=edge[i].to; 32

Node.js 命令行工具的编写

好久不见. 提交于 2020-04-04 03:12:16
日常开发中,编写 Node.js 命令行工具来完成一些小任务是很常见的操作。其编写也不难,和日常编写 Node.js 代码并无二致。 package.json 中的 bin 字段 一个 npm 模块,如果在 package.json 中指定了 bin 字段,那说明该模块提供了可在命令行执行的命令,这些命令就是在 bin 字段中指定的。 package.json { "bin": { "myapp": "./cli.js" } } 程序安装后会可在命令行执行 myapp 命令,实际执行的就是指定的这个 cli.js 文件。如果是全局安装,会将这个目标 js 文件映射到 prefix/bin 目录下,而如果是在项目中安装,则映射到 ./node_modules/.bin/ 目录下。 比如上面的示例,全局安装后会将 cli.js 映射到 /usr/local/bin/myapp 目录下。 # 查看项目中安装的所有可执行模块 $ ll node_modules/.bin ... webpack -> ../webpack/bin/webpack.js ... 如果你的 npm 包只提供了一个可执行的命令,可直接将 bin 字段设置为目标文件,此时命令行中可执行的 CLI 命令名为 npm 包名(即 name 字段)。 { "name": "my-program", "version":

Delphi对于文件的读写操作

假装没事ソ 提交于 2020-04-04 01:13:23
delphi文件操作 取文件名 ExtractFileName(FileName); 取文件扩展名: ExtractFileExt(filename); 取文件名,不带扩展名: 方法一: Function ExtractFileNameNoExt(FileString: String): String; Var FileWithExtString: String; FileExtString: String; LenExt: Integer; LenNameWithExt: Integer; Begin FileWithExtString := ExtractFileName(FileString); LenNameWithExt := Length(FileWithExtString); FileExtString := ExtractFileExt(FileString); LenExt := Length(FileExtString); If LenExt = 0 Then Begin Result := FileWithExtString; End Else Begin Result := Copy(FileWithExtString,1,(LenNameWithExt-LenExt)); End; End; 方法二: ChangeFileExt

Delphi7文件操作常用函数

风格不统一 提交于 2020-04-04 01:12:55
1. AssignFile、Erase AssignFile procedure AssignFile(var F; FileName: string);:给文件变量连接一个外部文件名。这里需要注意的是AssignFile不能用在已打开的文件上。 procedure TForm1 .Button1Click(Sender: TObject); var text : String; F1 : TextFile; begin Try AssignFile(F1,Trim(Edit1 .Text)); //变量与外部文件名关联 Append(F1); text := Memo1 .Text; write(f1,text); CloseFile(f1); //终止变量与外部文件的关联 Except ShowMessage( '写入失败'); End; end; Erase procedure Erase(var F);:删除一个外部文件。 AssignFile(MyFile, 'd:\dd.txt'); Erase(MyFile); //必须关闭一个文件后才可以删除它 2.ChDir procedure ChDir(const S: string); overload; procedure ChDir(P: PChar); overload; 将当前目录修改为指定目录。其中S