I have the following code:
class SegmentTree {
public:
unordered_map<int, int> tree;
vector<int> nums;
SegmentTree(vector<int> nums) {
this->nums = nums;
build(0, nums.size() - 1, 1);
}
};
class NumArray {
public:
SegmentTree s;
NumArray(vector<int> nums) {
s = SegmentTree(nums);
}
};
I am getting an error saying
note: candidate expects 1 argument, 0 provided
Presumably SegmentTree is being initialized when I do SegmentTree s
.
However, I want to initialize it only within the constructor of NumArray
.
How do I accomplish this?