简体   繁体   中英

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

I have an MFC project. So in this project I have created an isolated C++ class (one source file one header file), not MFC class. 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'.

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.

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?

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.

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!).

In your case, you may want to consider std::vector or std::list .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM