Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio

Eche un vistazo a continuación

1 de 2 Anuncio

Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx

Descargar para leer sin conexión

Write a function called HugeInteger *hugeDestroyer(HugeInteger *p);
Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks.
Returns: NULL
There is also this to use:
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
Solution
#include<iostream>
using namespace std;
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
HugeInteger *hugeDestroyer(HugeInteger *p){
delete []p;
return NULL;
}
int main(){
HugeInteger *p = new HugeInteger[10];
if(hugeDestroyer(p) == NULL)
cout<<\"All memory is deallocated\";
return 0;
}
.

Write a function called HugeInteger *hugeDestroyer(HugeInteger *p);
Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks.
Returns: NULL
There is also this to use:
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
Solution
#include<iostream>
using namespace std;
typedef struct HugeInteger
{
// a dynamically allocated array to hold the digits of a huge integer
int *digits;
// the number of digits in the huge integer (approx. equal to array length)
int length;
} HugeInteger;
HugeInteger *hugeDestroyer(HugeInteger *p){
delete []p;
return NULL;
}
int main(){
HugeInteger *p = new HugeInteger[10];
if(hugeDestroyer(p) == NULL)
cout<<\"All memory is deallocated\";
return 0;
}
.

Anuncio
Anuncio

Más Contenido Relacionado

Similares a Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx (20)

Más de lez31palka (20)

Anuncio

Más reciente (20)

Write a function called HugeInteger -hugeDestroyer(HugeInteger -p)- De.docx

  1. 1. Write a function called HugeInteger *hugeDestroyer(HugeInteger *p); Description: Destroy any and all dynamically allocated memory associated with p. Avoid segmentation faults and memory leaks. Returns: NULL There is also this to use: typedef struct HugeInteger { // a dynamically allocated array to hold the digits of a huge integer int *digits; // the number of digits in the huge integer (approx. equal to array length) int length; } HugeInteger; Solution #include<iostream> using namespace std; typedef struct HugeInteger { // a dynamically allocated array to hold the digits of a huge integer int *digits; // the number of digits in the huge integer (approx. equal to array length) int length; } HugeInteger; HugeInteger *hugeDestroyer(HugeInteger *p){ delete []p;
  2. 2. return NULL; } int main(){ HugeInteger *p = new HugeInteger[10]; if(hugeDestroyer(p) == NULL) cout<<"All memory is deallocated"; return 0; }

×