0

Possible Duplicate:
Is there a difference in C++ between copy initialization and direct initialization?

class Animal{};

int main(){    
  Animal white_cat;
  Animal black_cat(white_cat);
  Animal brown_cat = white_cat;    
}

I know here both initialization done by copy constructor. But performance or memory wise are there any different among these two initializing? Animal black_cat(white_cat); Animal brown_cat = white_cat; If not why are there two way to do the same thing?

Community
  • 1
  • 1
Nayana Adassuriya
  • 23,596
  • 30
  • 104
  • 147
  • `Animal black_cat(white_cat);` is **Direct Initialization**. While, `Animal brown_cat = white_cat;` is **Copy Initialization**. – Alok Save Oct 01 '12 at 11:58
  • @LucianGrigore: The are defined to have the same effect because `white_cat` has type `Animal`. – CB Bailey Oct 01 '12 at 12:00

0 Answers0