示例#1
0
int main () {
	CRectangle recta(3,4);
	CRectangle rectb(5,6);
	CRectangle rectc;
	recta.set_values(4,4);
	
	cout << rectc.n << endl;
	cout << "recta area: " << recta.area()<<endl;
	cout << "rectb area: " << rectb.area()<<endl;
	cout << "rectc area: " << rectc.area()<<endl;


	CRectangle a;
	CRectangle *pb = new CRectangle;
	CRectangle *pc = &a;
	CRectangle *pe = new CRectangle(3,4);
	CRectangle *pd = new CRectangle[2];

	a.set_values (1,2);
	pd->set_values (5,6);
	pd[1].set_values (7,8);


	cout << "a area: " << a.area() << endl;
	cout << "b area: " << pb->area() << endl;
	cout << "*c area: " << pc->area() << endl;
	cout << "d[0] area: " << pd[0].area() << endl;
	cout << "d[1] area: " << pd[1].area() << endl;
	cout << "e area: " << pe->area()<<endl;
	
	if ( pc->isitme(a) )
            cout << "yes, &a is pc"<<endl;
	return 0;
}	
int main () {
//first example
    CRectangle rect;
    rect.set_values (3,4);
    cout << "area: " << rect.area() << "\n";
//example of internal vs external class func defn
    CRectangle_internal rect_internal;
    cout << "area internal: " << rect_internal.area() << "\n";
    rect_internal.set_values(3,4);
    cout << "area internal: " << rect_internal.area() << "\n";
//example of multiple instances
    CRectangle rectb;
    rectb.set_values(5,6);
    cout << "areab: " << rectb.area() << "\n";
//constructors
    CRectangle_con rectc;
    CRectangle_con rectd (5,6);
    cout << "rectc area: " << rectc.area() << endl;
    cout << "rectd area: " << rectd.area() << endl;
//destructor
//implicit default
//  CRectangle_implicit rect_implict (2,3);
//  CRectangle_implicit rect_implicit2 (rect_implicit);
//  cout << "rect_implict: " << rect_implict.area() << endl;
//  cout << "rect_implict2: " << rect_implict2.area() << endl;

//  CExample ex (2,3);
//  CExample ex2 (ex);

//pointers



    return 0;
}
示例#3
0
int main(){
  CRectangle rect;
  rect.set_values(3, 4);
  cout << "area: " << rect.area();
  
  return 0;
}
示例#4
0
int main() {
  CRectangle rect;
  CTriangle trgl;
  rect.set_values(4,5);
  trgl.set_values(4,5);
  cout << rect.area() << endl;
  cout << trgl.area() << endl;
  return 0;
}
示例#5
0
int main(){
	CRectangle rect;
	CTriangle trgl;
	rect.set_values(4, 5);
	trgl.set_values(4, 5);
	rect.output(rect.area());
	trgl.output(trgl.area());
	return 0;
}
示例#6
0
int main () {

  CRectangle rect;

  rect.set_values (3,4);

  printf("Rect Area : %i\n", rect.area());	

  return 0;

}
示例#7
0
文件: learn.cpp 项目: ghostceo/ghost
void Learn::test(){
	CRectangle a, *b, *c;
    CRectangle * d = new CRectangle[2];
    b= new CRectangle;
    c= &a;
    a.set_values (1,2);
    b->set_values (3,4);
    d->set_values (5,6);
    d[1].set_values (7,8);
    cout << "a area: " << a.area() << endl;
    cout << "*b area: " << b->area() << endl;
    cout << "*c area: " << c->area() << endl;
    cout << "d[0] area: " << d[0].area() << endl;
    cout << "d[1] area: " << d[1].area() << endl;
}
int main () {
  CRectangle a, *b, *c;
  CRectangle * d = new CRectangle[2];
  b= new CRectangle;
  c= &a;
  a.set_values (1,2);
  b->set_values (3,4);
  d->set_values (5,6);
  d[1].set_values (7,8);
  cout << "a area: " << a.area() << endl;
  cout << "*b area: " << b->area() << endl;
  cout << "*c area: " << c->area() << endl;
  cout << "d[0] area: " << d[0].area() << endl;
  cout << "d[1] area: " << d[1].area() << endl;
  delete[] d;
  delete b;
  return 0;
}
示例#9
0
文件: main.cpp 项目: ssvlab/esbmc-gpu
int main () {
	CPolygon* polygons[4];
	
	polygons[0] = new CRectangle(20,30);
	polygons[1] = new CTriangle(20,25);
	polygons[2] = new CCircle(25,25);
	polygons[3] = new CSquare(18,18);
	
	for(int i = 0; i < 4; i++)
	{
		CTriangle* trin = dynamic_cast <CTriangle *> (polygons[i]);
		if (trin != 0)
		{
			trin->set_values(10, 10);
			assert(trin->area() != 50);
		}
		
		CCircle* circ = dynamic_cast <CCircle *> (polygons[i]);
		if (circ != 0)
		{
			circ->set_values(10, 10);
			assert(circ->area() != 78);
		}
		
		CSquare* sqrr = dynamic_cast <CSquare *> (polygons[i]);
		if (sqrr != 0)
		{
			sqrr->set_values(10, 10);
			assert(sqrr->area() != 100);
		}
		
		CRectangle* rect = dynamic_cast <CRectangle *> (polygons[i]);
		if (rect != 0)
		{
			rect->set_values(10, 20);
			assert(rect->area() != 200);
		}
		
	}
/*
*/

  return 0;
}