簡體   English   中英

CPtrList 無法使用:錯誤 C2248:“CObject::operator =”:無法訪問類“CObject”中聲明的私有成員

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

我有一個 MFC 項目。 所以在這個項目中我創建了一個獨立的 C++ 類(一個源文件一個頭文件),而不是 MFC 類。 在這個 C++ 類頭文件中,我聲明了一個 CPtrList(甚至沒有在源文件中使用它),但是在編譯時出現錯誤:C2248: 'CObject::operator =' : cannot access private member declaration in class 'C對象'。

我所擁有的只是一個聲明。 我最初認為這是因為我應該在頭文件的開頭 #include "afxcoll.h" 但它不是在嘗試之后。

不知道出了什么問題。 請問有什么幫助嗎?

下面是頭文件。 不會編譯。

#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);

};

那么,您是否有在其中使用CPtrList數據成員的自定義類?

然后,根據錯誤消息,您可能正在嘗試復制您的類,而編譯器無法復制,因為CPtrList (與其他幾個舊的 MFC 容器一樣)是不可復制的。

我真的建議使用STL 容器而不是 MFC 容器(無法復制,有些甚至使用某種形式的“恐怖” memcpy()進行復制!)。

在您的情況下,您可能需要考慮std::vectorstd::list

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM