[Dev-C++] C++ Question (the real one)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ya...> - 2001-04-21 20:01:37
|
Ok i was stupid for my previous question. The answer is because it was a
friend function. Here is the real question:
#include <iostream>
class Matrix
{
double m[4][4];
public:
void test(Matrix s);
};
void Matrix::test(Matrix s)
{
for (int i=0; i<4; i++)
{
std::cout<<std::endl;
for(int j=0; j<4; j++)
std:: cout<<s.m[i][j]<<std::endl;
}
}
int main()
{
return 0;
}
The member function test() accesses the private data member of its argument
directly. When is it allowed for functions to access directly the private
members of their arguments except of those declared as friends?
Thanks in advance,
Ioannis
* Ioannis Vranos
* Programming pages: http://members.nbci.com/noicys
* Alternative URL: http://run.to/noicys
|