vs2010下编译出现error C2248的问题,请哪位大侠指正

flybird70 2011-03-10 12:35:35
// ww.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include<fstream>
#include <algorithm>
using namespace std;
#include "combination.h"
class MyCombs : public Combination
{
private:

void Filter0()
{
list<ByteArray>::iterator iter;
for( iter = this->begin(); iter != this->end(); )
{
ByteArray& array = *iter;

int T=0;
int a=array[0];int b=array[1];int c=array[2];

if( a==1)T=1;

if( T==1)
{
list<ByteArray>::iterator old_iter = iter;
iter++;
this->erase(old_iter);
} else {
iter++;
}
}
}
public:
MyCombs(byte m, byte n) :
Combination(m, n)
{
}
void Filter() {

Filter0();

}
};

int _tmain(int argc, _TCHAR* argv[])
{
MyCombs combs(9, 3);

combs.GenerateCombination();
fstream outfile;
outfile.open("array.text",ios::out);
cout << "result is : " << endl;
cout << combs << endl;
outfile << combs << endl;


return 0;
}

以上是程序代码
...全文
247 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
haoshenwang 2011-11-30
  • 打赏
  • 举报
回复
写个get函数,返回私有变量
flybird70 2011-03-10
  • 打赏
  • 举报
回复
vs2010下编译出现错误:
c:\program files\microsoft visual studio 1.0\vc\include\ostream(604) : error C2248: “std::basic_ios <_Elem,_Traits>::basic_ios”: 无法访问 private 成员(在“std::basic_ios <_Elem,_Traits>”类中声明)
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits <char>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\ios(151) : 参见“std::basic_ios <_Elem,_Traits>::basic_ios”的声明
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits <char>
1> ]
1> 此诊断出现在编译器生成的函数“std::basic_ofstream <_Elem,_Traits>::basic_ofstream(const std::basic_ofstream <_Elem,_Traits> &)”中
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits <char>
1> ]

相同的用法在vs6.0下就没有这样的问题;

提示是禁止访问私有成员,可是不知道怎样修改,请大侠帮我解决一下吧,谢谢!
flybird70 2011-03-10
  • 打赏
  • 举报
回复
我查了一些帖子:

vs2008下,从“类”创建的对象无法访问该“类”的 protected 或 private 成员,不可以执行拷贝构造函数

解决方法:自己编写新类的复制构造函数和赋值构造函数:

可是怎么没有解决问题

65,208

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧