Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/152.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 连接两个不同的对象向量<;t>;按变量_C++_Vector - Fatal编程技术网

C++ 连接两个不同的对象向量<;t>;按变量

C++ 连接两个不同的对象向量<;t>;按变量,c++,vector,C++,Vector,我不确定如何合并两个向量 std::vector<MONITORINFOEX> newList std::vector<SingleMonitorInfo> oldList std::vector newList 向量oldList 它需要将newList[i].szMonitor(WCHAR[32])与oldList[j].szMonitor(WCHAR[32])进行比较,并计算出每个newList[i].rcMonitor(RECT)与oldList[j].rcM

我不确定如何合并两个向量

std::vector<MONITORINFOEX> newList
std::vector<SingleMonitorInfo> oldList
std::vector newList
向量oldList
它需要将
newList[i].szMonitor(WCHAR[32])
oldList[j].szMonitor(WCHAR[32])
进行比较,并计算出每个
newList[i].rcMonitor(RECT)
oldList[j].rcMonitor(RECT)

其中:

  • 我是新名单上的所有监视器
  • j是旧列表中的所有监控器

然后连接、连接、合并列表为一个(如果它们是相同的szMonitor和resolution),然后只需要将newList中的两个RECT变量更新为oldList:同时删除任何对象(monitor)在不在newList中的oldList中添加任何在newList中但不在oldList中的对象。

这两个对象不能位于同一容器中,除非一个继承另一个或它们都继承同一类;但是,如果这些类与中的类相同,则可以从
MonitorInfo
@Tas创建
SingleMonitorInfo
。是的,它们是相同的类。我可以使用oldList.push_back(SingleMonitorInfo(MonitorInfo))。我必须像使用数组而不是使用向量一样对其进行编码吗?这两个对象没有办法放在同一个容器中,除非一个继承另一个或它们都继承同一个类;但是,如果这些类与中的类相同,则可以从
MonitorInfo
@Tas创建
SingleMonitorInfo
。是的,它们是相同的类。我可以使用oldList.push_back(SingleMonitorInfo(MonitorInfo))。我是否必须用与使用向量相反的数组对其进行相同的编码?