Beispiel #1
0
int main()
{
  IntCell m;
  IntCell n;

  m.write(5);
  n.write(2);

  IntCell o = m + n;
  IntCell p = m - n;
  cout << "Cell contents m: " << m << endl;
  cout << "Cell contents n: " << n.read() << endl;
  cout << "Cell contents o: " << o.read() << endl;
  cout << "Cell contents p: " << p.read() << endl;
  return 0;
}
Beispiel #2
0
        int main( )
        {
            IntCell m;   // Or, IntCell m( 0 ); but not IntCell m( );

            m.write( 5 );
            std::cout << "Cell contents: " << m.read( ) << std::endl;

            return 0;
        }
Beispiel #3
0
        int main( )
        {
            IntCell m;

            m.write( 5 );
            std::cout << "Cell contents: " << m.read( ) << std::endl;

            return 0;
        }
//this builds a vector of iCells of 'size' size
vector<IntCell> iCells(int size){
	vector<IntCell> intcells;
	for(int i = 0; i < size; i++){
		IntCell j;
		j.write(i);
		intcells.push_back(j);
	}
	return intcells;

}
Beispiel #5
0
int main()
{
	IntCell obj;

	/* 使用explicit意味着单参数构造函数不能用来创建隐式临时对象 
	 * 编译以下两句会得到如下错误
	 * note: candidate function (the implicit copy assignment operator) 
	 * not viable: no known conversion from 'int' to 'const IntCell' for 1st argument
	 */
	// obj = 37;

	obj.write(666);
	std::cout << obj.read() << "\n";


	return 0;
}