does adding a dummy parameter to constructors of a class to solve calling ambiguity,

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pooria
    New Member
    • Jul 2010
    • 8

    does adding a dummy parameter to constructors of a class to solve calling ambiguity,

    take following class and two object definitions:

    Code:
    class Rect{
     public:
      enum centimeter;
      enum meter;
      Rect(double len,double wid,enum centimeter){
       length=(len/100);
       width=(wid/100);
      }
      Rect(int len,int wid,enum meter){
       length=len;
       width=wid;
      }
      //rest of implementation
     private:
      double length;//in meters
      double width;//in meters
    };
    Rect obj1(10,5,Rect::centimeter());
    Rect obj2(10,5,Rect::meter());
    two previous constructors have dummy enum parameters to solve calling ambiguity caused in case these dummy parameters didn't exist. Now in spite of possibility of using named constructors here, if I insist on using these dummy parameters, does this violate any coding rule that I should be aware of ?
Working...