Re: C++ initialization problem with nested constructors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Stuart,

>   C c2(B(a));

This declares a function named c2 which takes a parameter B, and returns C.

You can fix this by one of:
//1
  C c2((B)B(a));

//2
  C c2 = C(B(a));

//3
  B b(a);
  C c2(b);

//4
  B b(a);
  C c2 = C(b);

//5
  C c2((B(a)));

Personally, I like #3 best, or #4 next best, and #2 also acceptable.  For
me, #1 and #5 are not acceptable.  But if your class accommodated it, I'd
rather have:
  B b(a);
  C c2 = b;

HTH,
--Eljay


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux