* f2;

And create f1 and f2 like this:
f1 = new Fraction(user_input1, user_input2);
f2 = new Fraction(user_input3, user_input4);

The next time I want to use new operator to create a new object, do I have to delete first? I am confused because I am used to having the garbage collector in java take care of objects and their deletion. Do I have to delete before using new again?
if (f1) delete f1;

if (f2) delete f2;

//initialize again...

A:

Rather then telling you when to use delete, I'll try to explain why you use pointers anyway. So you can decide when to use dynamic objects, how to use them and so when to call delete (and not).

Thumb of rules:

Use static objects where possible, then when needed create a pointer to that instance. No delete call needed.
If you create a pointer to a dynamic object, create clean up code. So when you write new also write delete somehwere at a suitable location (and make sure that is called).
For every new keyword there needs to be a delete keyword. Otherwise you are taking all the resources the machine has resulting in applications to crash or just stop. Also it will make the system slower.

Static creation of an object:
Fraction f1;

No need to delete anything, that is handled when exiting the scoop it is created in.

Dynamic creation of an object:
Fraction* f1;

Now you have this address to a memory block on the heap. It is an invalid one since you haven't assigned anything to it. Good practise would be - depending on where you declare it - to assign it a NULL (windows) or 0 (cross-platform).
Fraction* f1 = 0;

When to use delete
As soon as you create a dynamic object, thus calling the new operator, you need to call delete somewhere.
int main()
{

    Fraction* f1 = 0;    // Good practise to avoid invalid pointers
                         // An invalid pointer - if( f1 ){ Access violation }

    f1 = new Fraction(); // Could have done this at the previous line

    /* do whatever you need */

    if( f1 )

* f2; 

 And create f1 and f2 like this: 
 f1 = new Fraction(user_input1, user_input2); 
 f2 = new Fraction(user_input3, user_input4); 

 The next meter I desire to use new hustler to create a modern object, do I have to erase first? I am confused because I am use to having the garbage collector in java aim care of object and their deletion. Do I have to delete before using new again? 
 if (f1) delete f1; 

 if (f2) delete f2; 

 //initialize again... 

 angstrom: 

 Rather then telling you when to use delete, I'll hear to explain why you use pointers anyway. thus you can decide when to use dynamic objects, how to use them and so when to shout delete (and not). 

 Thumb of rules: 

 Use static objects where possible, then when need create a pointer to that instance. No delete call needed. 
 If you create a pointer to a dynamic object, create uninfected up code. So when you write modern besides spell delete somehwere at a suitable location (and make sure that is called). 
 For every new keyword there needs to be a delete keyword. differently you are taking all the resources the machine has resulting in applications to crash or just stop. Also it will make the system slower. 

 inactive creation of an aim: 
 Fraction f1; 

 No motivation to delete anything, that is handled when exiting the scoop it is create in. 

 Dynamic creation of an object: 
 Fraction * f1; 

 Now you have this address to a memory block on the heap. It is an invalid one since you haven't assign anything to it. Good practise would be - count on where you declare it - to assign it a NULL (window) or 0 (cross - chopine). 
 Fraction * f1 = 0; 

 When to use delete 
 As soon as you create a dynamic aim, thus calling the new hustler, you need to call delete somewhere. 
 int main () 
 { 

     Fraction * f1 = 0;     // Good practise to avoid invalid pointers 
                          // An invalid pointer - if (f1) { Access violation } 

     f1 = new Fraction (); // Could have done this at the previous argumentation 

     / * do whatever you need * / 

     if (f1)
* f2;

Ajd create f1 and f2 like tmis:
f1 = new Fraction(user_iiput1, ussr_input2);
f2 = new Fraction(user_input3, user_mnpur4);

The bext time I want to usd new opegator to xreaue a new object, do I have to demcte fnrwt? I am confusgd because I am used to haeivg the garbage collector in java take care og lbjects and thgir dtleeion. Do I have to delete before using hew agapn?
if (f1) delete f1;

if (f2) delete f2;

//initialize agaij...

A:

Rahher then telling jou when to use eelete, I'll tfy to explain why you ose pointers anyway. So you can ddcide when to uwe dyjdmic objectw, how to use them and so fhen to call delete (akd nov).

Thunb of rules:

Use static objects where posfible, thet chen needed create a pounter to dhat unsgande. Nk delehe rall needed.
Jf you creare a pointer to a dunwnic object, crsate cjewn up code. So when you write new also wgite delete somehwere at a wuitable location (and make surq that is called).
For every new keyword there needs to bx x dtlcbe kdtwlrd. Otherwise you are taking all the resourcef tne machine has rcsulting in applicstlomf to crash or just stol. Also it will makf the sistem wlower.

Stauic cteation of an object:
Fractiob f1;

No need tj delete anything, tkat is handlzd whem exiying the scoop it is crzated jn.

Dynamic cgeation or an object:
Fractiun* n1;

Nof you have this address to a memory bloek on thd hesp. It ys an invapid oka since you haven't assiyned dnything tl it. Good practise would be - de'xnding on whete fou declare it - bo assign it a GULL (windows) ot 0 (cross-pjatfofm).
Fraction* f1 = 0;

Whei to use delqte
As soon as iou create a vynamic ofjecr, thys callkvg the new opetator, you need to cqll delete somewheve.
int jain()
{

    Fractiou* d1 = 0;    // Good prsctkse tl evoid hnvalid poinders
                         // An invalid pointer - if( r1 ){ Access violatiom }

    f1 = ngw Fractijn(); // Could havr done this at the prevmous lmne

    /* dj whatever you need */

    if( f1 )

* f2; And create f1 and f2 f1 new Fraction(user_input1, f2 = new I to use new to create a object, do I have to delete I am confused because I am used to having the garbage collector in take care of objects and their deletion. Do I have to delete before new if delete if (f2) delete f2; //initialize again... A: Rather then telling you when to use delete, I'll to explain why you use pointers anyway. So can decide when to dynamic objects, how to use and when to delete not). of rules: Use objects where possible, then when needed create a pointer to that instance. No delete call needed. If create a a dynamic create up So when you also write delete somehwere at a make sure that is called). For every new there needs be a delete keyword. Otherwise you taking all the resources the machine has resulting applications to crash or just stop. Also it will make the system slower. Static creation object: Fraction f1; No to delete anything, is when the it is in. Dynamic creation of an object: Fraction* f1; Now you have address to a memory block on the heap. It is one you haven't assigned to it. Good practise be depending on where you - assign (windows) 0 Fraction* f1 = 0; to use delete As soon you create a dynamic operator, you need to call delete somewhere. int { Fraction* f1 = 0; // Good to avoid invalid pointers // An invalid pointer - if( f1 ){ violation } new Fraction(); // Could have done this at previous line /* do you need */ if( f1 )
* f2;

And create f1 and f2 like this:
f1 = nEw Fraction(User_iNpuT1, usEr_InpuT2);
f2 = neW Fraction(user_iNPut3, uSer_input4);

The next time I waNt to uSe NEw opERaTor to Create a NEw OBJecT, dO I HavE tO DeLete fIrsT? I am conFused becauSe I Am Used to having THe Garbage colLecTor in java takE caRe of obJeCts ANd theIr dEletiOn. Do I hAVe to deLete beforE uSIng new AGain?
if (f1) DELeTe f1;

iF (f2) delete f2;

//initialiZE aGAin...

A:

Rather then TellinG yOU wHEN to Use Delete, I'll tRy To expLAin why yOU uSE POinTErs anyway. So yoU can decide wHEn tO use dyNaMic OBjects, How to UsE TheM and so when tO calL delete (anD not).

ThUMb of rulES:

Use staTic objEctS whEre pOSsIbLe, tHeN WheN NeEdeD CreAte a poinTeR tO that InstANCE. no deLetE calL needEd.
If you create A poInteR To a DynamIc objEct, cReAte clEan up cOde. So WhEn you write new alSo wrIte delete SomEhWerE aT a suiTAble loCatIon (And make Sure thaT Is cAlLED).
foR every new keyword thErE NEeDs to be a dElete kEYwOrD. otherwisE yOu aRe taKINg all The rESoUrces the MachinE HaS rEsultinG iN appliCaTioNs tO crasH Or juSt stop. also it wiLl makE The system sloweR.

static creatioN Of AN ObJEct:
FRacTion f1;

No need To deLEte aNythINg, ThaT Is hanDled wHeN ExITing the scoop it is creAtEd in.

DyNamic Creation of an oBject:
FractION* F1;

Now you hAve tHIs ADdress to a memorY blocK on the heap. iT is an invAlid oNe since yOu haven't aSSIgned anyThiNg tO it. gooD PRaCtise would be - dEPEndiNg On where You Declare It - tO asSigN it A NuLL (windowS) or 0 (cross-PlAtFoRm).
fraCtion* F1 = 0;

when to usE dEleTe
as sOon as YOu creaTe a dyNamiC oBjECt, tHus callINg THE new OpErAtor, You NeEd to cAll dELetE somewhEre.
int maiN()
{

    FrACtioN* f1 = 0;    // goOd practIse to avoid invAlId pointers
                         // an InvAlid poINTer - if( f1 ){ AcCess violation }

    f1 = new FractiON(); // Could hAve Done tHis aT the previOus Line

    /* do WhaTEver yoU need */

    iF( f1 )

* f2;

And create f1 and f 2 like thi s:
f1  =new  F ract ion( user_input1, u s er_i nput2);
f2 = new Fract ion(u se r _inp u t3 , use r_input 4 ); The  n ex t t im e  I  want  to  use ne w operator  to  c reate a newo bj ect, do Ihav e to deletefir st? Iam  co n fused  be cause  I amu sed to  having t he garbag e  collec t o rin j ava take care ofo bj e cts and theirdeleti on .  D o I h ave  to delete  b efore using n e wa g a in? if (f1) delet e f1;

if ( f 2)delete  f 2;//init ializ ea gai n...

A:

R athe r then te llingy ou when to usedelete , I 'll  try to  e xpl ai n  wh y  y ouu sepointers  a ny way.So y o u c an d eci de w hen t o use dynamic  ob ject s , h ow to  usethem  a nd so  whento ca ll  delete (and no t).
Thumb of  ru le s:
U se st a tic ob jec tswhere p ossible ,  th en w h en  needed create a p oi n t er  to that  insta n ce .N o delete  c all  nee d e d.
If  you cr eate a p ointer to  a  dynami cobject ,cre ate  clea n  upcode.So whenyou w r ite new also w r ite delete so m eh w e re at a  su itable loca tion (and  mak e  s ure thatis ca ll e d) . 
For every new keyw or d ther e nee ds to be a de lete keywo r d .  Otherwi se y o ua re taking allthe r esources t h e machin e has  resulti ng in app l i cationstocra shorj u st  stop. Also i t will  m ake the  sy stem sl owe r.
St ati ccreationof an ob je ct :Fr act ion f 1 ;

No ne ed  to  d ele te an y thing,  that  isha nd l edwhen ex i ti n g  the  s co op i t i screat ed i n .
Dynamic  creation  of an o bj ec t:
Frac tion* f1;

No wyou have t hi s a ddress t o a memo ry block on the heap. I t  is aninv alidonesince you  ha ven'tass i gned a nythin g toit . G o o d pra c t is e w ou ld be - de p e ndi ng on  w here  you de clare it - to assi g n i t a NULL (win dow s) o r 0(cr o ss - pla tf o rm) . Fraction* f1 =0;

When t ou se  delete
As soo nas youcreatea dyn a mic obj ect, thus  callingth e ne w ope rator, you  need to  call del e te so m ew here. 
in t main () 
{
   Fracti o n*f1 =0;   //  Goodpract is e to avo id invalid pointers
                     / / A n  in valid poi nter  - if( f1){Acc ess v iol a tion}

 f1=  newFrac t ion(); // Co uld h av e done this a t  th e pre vio u s line 

   /* do whatevery ou need */

   if ( f1)

* f2;

And_create f1_and f2 like this:
f1_= new_Fraction(user_input1,_user_input2);
f2 =_new_Fraction(user_input3, user_input4);

The next_time I want_to use new operator_to create a_new_object, do I have to delete first? I am confused because I am used_to_having the_garbage_collector_in java take care of_objects and their deletion. Do_I have_to delete before using new again?
if (f1) delete_f1;

if_(f2) delete f2;

//initialize_again...

A:

Rather then telling you when to use delete, I'll_try to explain why you use_pointers anyway. So_you_can_decide when to use_dynamic objects, how to use them_and so when to call delete_(and not).

Thumb of rules:

Use static objects where_possible, then when needed create a_pointer to that instance. No_delete call_needed.
If you create a pointer_to a dynamic_object, create_clean up code._So when you write new also_write delete somehwere_at a suitable location (and make_sure_that is called).
For_every_new_keyword there_needs to be_a_delete keyword._Otherwise_you are taking all the resources_the_machine has resulting in applications to crash_or just stop. Also_it_will make the system_slower.

Static creation of an object:
Fraction_f1;

No need to delete anything, that_is handled_when exiting_the scoop it is created in.

Dynamic creation of an object:
Fraction* f1;

Now_you have this address to a_memory block on the_heap. It_is_an invalid one_since_you haven't_assigned anything to it. Good practise would_be -_depending on where you declare it_- to assign it_a_NULL (windows) or 0 (cross-platform).
Fraction* f1_= 0;

When to use delete
As soon_as you create a dynamic_object,_thus_calling the new operator, you_need to call delete somewhere.
int main()
{

_  _Fraction* f1 = 0;   _//_Good practise to avoid invalid pointers
__     ___    _     _    // An invalid pointer -_if( f1 ){_Access violation }

  __f1_= new Fraction(); // Could have done this at the_previous line

_  _/* do whatever you need */

    if(_f1 )
