简体   繁体   English

CPtrList 无法使用:错误 C2248:“CObject::operator =”:无法访问类“CObject”中声明的私有成员

[英]CPtrList cannot use: error C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'

I have an MFC project.我有一个 MFC 项目。 So in this project I have created an isolated C++ class (one source file one header file), not MFC class.所以在这个项目中我创建了一个独立的 C++ 类(一个源文件一个头文件),而不是 MFC 类。 And in this C++ class header file I declared a CPtrList (without even using it in source file), but when it comes to compilation, there comes the error: C2248: 'CObject::operator =' : cannot access private member declared in class 'CObject'.在这个 C++ 类头文件中,我声明了一个 CPtrList(甚至没有在源文件中使用它),但是在编译时出现错误:C2248: 'CObject::operator =' : cannot access private member declaration in class 'C对象'。

All I have is a declaration.我所拥有的只是一个声明。 I initially thought it was because that I should #include "afxcoll.h" at the beginning of the header file but it was not after trying.我最初认为这是因为我应该在头文件的开头 #include "afxcoll.h" 但它不是在尝试之后。

No idea what's wrong.不知道出了什么问题。 Any help please?请问有什么帮助吗?

below is the header file.下面是头文件。 wouldnt compile.不会编译。

#pragma once
#include <iostream>
#include <opencv\cv.h>
#include <opencv\highgui.h>
#include "stdafx.h"

class CMonitor
{
public:
CMonitor(void);
~CMonitor(void);

int horizontalPartition;
int verticalPartition;
int height;
int width;
int differenceThreshold;

bool intrusionIndicator;
bool setMatDimension;
bool setPartition;

int dequePresetSize;
//std::deque<cv::Mat> matDeque;
//CPtrList pMatList;

//Testing purposes:
int currentAvg;
int historyAvg;

void DrawGrid(cv::Mat& img, int verticalPartitionNo, int horizontalPartitionNo);
void PutDebugText(cv::Mat& img);

void MonitorDatabaseUpdate(cv::Mat img);
int SingleCellInHistoryDatabaseAvgComputing(int top, int left, int bottom, int right);
int SingleCellAvgComputing(int top, int left, int bottom, int right);
bool CMonitor::Detector();

void SetPartitionInfo(int horizontalPartition, int verticalPartition);

}; };

So, do you have a custom class inside of which you use a CPtrList data member?那么,您是否有在其中使用CPtrList数据成员的自定义类?

Then, from the error message, probably you are trying to copy your class, and the compiler can't do that because CPtrList (as several other old MFC containers) is not-copyable.然后,根据错误消息,您可能正在尝试复制您的类,而编译器无法复制,因为CPtrList (与其他几个旧的 MFC 容器一样)是不可复制的。

I really suggest using STL containers instead of MFC containers (which cannot be copied, and some even use some form of "horror" memcpy() for copy!).我真的建议使用STL 容器而不是 MFC 容器(无法复制,有些甚至使用某种形式的“恐怖” memcpy()进行复制!)。

In your case, you may want to consider std::vector or std::list .在您的情况下,您可能需要考虑std::vectorstd::list

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误C2248:'CObject :: CObject':无法访问类'CObject'afxwin.h中声明的私有成员 - error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' afxwin.h 错误 C2248: 'CObject::CObject': 当我在 ZD7421054471AB272ZCEAC18FD97BBD237 - error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' when I calling hDC.SelectObject function in MFC 传递CList变量会给出错误C2248:&#39;CObject :: CObject&#39;:无法访问私有成员 - Passing CList variable gives error C2248: 'CObject::CObject' : cannot access private member &#39;CObject :: CObject&#39;:无法访问在类&#39;CObject&#39;中声明的私有成员 - 'CObject::CObject' : cannot access private member declared in class 'CObject' 错误C2248:无法访问在类中声明的私有成员 - Error C2248:cannot access private member declared in class 错误C2248:无法访问类中声明的私有成员 - error C2248: cannot access private member declared in class 无法访问在类“ CObject”中声明的私有成员 - Cannot access private member declared in class 'CObject' 无法访问在类“ CObject”中声明的私有成员? - Cannot access private member declared in class 'CObject'? 错误C2248:“ X :: operator =”:无法访问在类“ X”中声明的私有成员 - error C2248: 'X::operator =' : cannot access private member declared in class 'X' VS2013编译器:“ CObject :: CObject”:无法访问在类“ CObject”中声明的私有成员 - VS2013 compiler: 'CObject::CObject' : cannot access private member declared in class 'CObject'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM