[C con Clase] Asignar un puntero a un objeto?

Utopic utopic en ono.com
Vie Ene 1 19:58:47 CET 2010


Hola buenas, ahí vauna duda filosofica:

Tengo un objecto "rectangulo", con su dos coordenadas X e Y, su anchura y su 
altura, y una función que recibe otro rectangulo como uno de sus parámetros, 
por referencia. Asignar directamente el parametro (puntero) al objecto no 
copiaria los atributos, verdad? debo copiar los cuatro atributos "a mano":

void inicializacion( int uno, Rectangulo* rectangulo, int tres)
{
	Rectangulo rectangulo;
	rectangulo = _rectangulo; //Copia las coordenadas X, Y y el tamaño W, H?
}

void inicializacion( int uno, Rectangulo* rectangulo, int tres)
{
	Rectangulo rectangulo;

	//Así si, pero es mas "feo".
	rectangulo.x = rectangulo->x;
	rectangulo.y = rectangulo->y;
	rectangulo.w = rectangulo->w;
	rectangulo.h = rectangulo->h;
}

Gracias,

-- 
Utopic
Whoever has lived long enough to find out what life is, knows how deep a debt
of gratitude we owe to Adam, the first great benefactor of our race.  He
brought death into the world.
		-- Mark Twain, "Pudd'nhead Wilson's Calendar"




Más información sobre la lista de distribución Cconclase