#include <iostream>
using namespace std;
class A
{
private:
double m_i[10][10];
public:
A()
{
for (int i = 0 ; i < 10; i++)
for (int j = 0; j< 10; j++)
m_i[i][j] = 0.0;
}
double &operator () (int i, int j=1)
{
return m_i[i][j];
}
};
int main()
{
A a;
a(1,3) = 40.3;
// cout << a.m_i[1][3] << endl; // m_i가 public일때 가능
cout << a(1,3) << endl;
return 0;
}
$ g++ a.cpp -W -Wall
$ ./a.out
20
댓글 없음:
댓글 쓰기