I can't catch this error, it must be something very easy. I have a header file (snim.h):
#ifndef SNIM_CLASS_HH_
#define SNIM_CLASS_HH_
#include <iostream>
namespace snim {
class SnimModel {
int communitySize; // Total size of the community
public:
SnimModel(int c) : communitySize(c) {};
friend std::ostream& operator<<(std::ostream&, const SnimModel&);
};
} /* end namespace */
#endif
and an implementation file:
#include "snim.h"
using namespace snim;
std::ostream& operator<<(std::ostream& os, const SnimModel& s) {
os << "[Total Size]\n[";
os << s.communitySize << "]\n";
return os;
};
Thus when I tried to compile it gives
In function ‘std::ostream& operator<<(std::ostream&, const snim::SnimModel&)’:
snim.cpp:9:11: error: ‘int snim::SnimModel::communitySize’ is private within this context
os << s.communitySize << "]\n";