社区讨论
求助为什么编译错误
学术版参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @lo2ld8ft
- 此快照首次捕获于
- 2023/10/23 15:44 2 年前
- 此快照最后确认于
- 2023/10/23 15:44 2 年前
本人用了各种搜索引擎无果,先求助于各位大佬们。
代码:
CPP//the code is from zhuziyu
#include<bits/stdc++.h>
#define lowbit(x) (x&-x)
using namespace std;
typedef long long LL;
struct Node{
int a;LL b;
Node(){b=a=0;}
Node(int _a,LL _b){a=_a,b=_b;}
Node operator + (const Node y)const{return Node(a+y.a,b+y.b);}
Node&operator += (const Node b){return *this=*this+b;}
};
template<typename T,const int SIZE>
struct fenwick_tree{
static T dt[SIZE+1];
fenwick_tree(){memset(dt,0,sizeof dt);}
fenwick_tree&operator=(const fenwick_tree y){memcpy(dt,y.dt,sizeof y.dt);return *this;}
void clear(){memset(dt,0,sizeof dt);}
void add(int x,const T v){assert(0<x&&x<=SIZE);for(;x<=SIZE;x+=lowbit(x))dt[x]+=v;}
T sum(int x){assert(0<x&&x<=SIZE);T ret;for(;x;x-=lowbit(x))ret+=x;return ret;}
/*
T ask(int x){
}
*/
};
int main(){
fenwick_tree<int,4> tr1;
fenwick_tree<int,4> tr2;
tr2=tr1;
return 0;
}
报错信息:
CPPC:\Users\ZZY\AppData\Local\Temp\cctYYJvR.o easy.cpp:(.rdata$.refptr._ZN12fenwick_treeIiLi4EE2dtE[.refptr._ZN12fenwick_treeIiLi4EE2dtE]+0x0): undefined reference to `fenwick_tree<int, 4>::dt'
C:\Users\ZZY\Desktop\collect2.exe [Error] ld returned 1 exit status
回复
共 1 条回复,欢迎继续交流。
正在加载回复...