求助为什么编译错误
  • 板块学术版
  • 楼主Zhu_Ziyu
  • 当前回复1
  • 已保存回复1
  • 发布时间2023/5/14 19:06
  • 上次更新2023/10/23 15:44:03
查看原帖
求助为什么编译错误
665925
Zhu_Ziyu楼主2023/5/14 19:06

本人用了各种搜索引擎无果,先求助于各位大佬们。

代码:

//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;
}

报错信息:

C:\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
2023/5/14 19:06
加载中...