【发布时间】:2014-08-07 07:32:12
【问题描述】:
我有一个 MFC 项目。所以在这个项目中,我创建了一个独立的 C++ 类(一个源文件一个头文件),而不是 MFC 类。在这个 C++ 类头文件中,我声明了一个 CPtrList(甚至没有在源文件中使用它),但是在编译时,出现了错误: C2248: 'CObject::operator =' : cannot access private member declared 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);
};
【问题讨论】:
-
删除第 5 行。那是错误……好吧,说真的,您是在寻找编程专家还是算命先生?不看代码我们怎么知道?
-
显示代码! (下次您发布问题时,一点常识不会出错)。
-
您的“非 MFC 类”假设不正确。 CPtrList 派生自 CObject。这使它成为一个 MFC 类。 C64先生的回答有很好的建议。
-
我附上了头文件的代码。请大家看看..