JavaScript:SpiderMonkey:C++ Coding Style: Difference between revisions

m
→‎Classical OOP: Four space softtab consistency in examples.
m (→‎Inline methods: Class definition bracing consistency.)
m (→‎Classical OOP: Four space softtab consistency in examples.)
Line 40: Line 40:
  class Fail
  class Fail
  {
  {
  size_t capacity_;  // unsightly
    size_t capacity_;  // unsightly
  T *mBegin;        // makes babies cry
    T *mBegin;        // makes babies cry
  T *m_end;          // much typing
    T *m_end;          // much typing
  }
  }
Sometimes a canonical argument name may conflict with a member name.  In this case, one can disambiguate with "this->", although such explicit qualification should only be added when necessary:
Sometimes a canonical argument name may conflict with a member name.  In this case, one can disambiguate with "this->", although such explicit qualification should only be added when necessary:
  class C
  class C
  {
  {
  size_t count;
    size_t count;
  bool fresh;
    bool fresh;
  void change(size_t count) {
    void change(size_t count) {
    this->count = count;
        this->count = count;
    this->fresh = false;  // verbose and unnecessary
        this->fresh = false;  // verbose and unnecessary
  }
    }
  };
  };
* Most macros become inline helpers. With LiveConnect gone on mozilla-central, we can make the helpers methods of relevant structs or classes finally, instead of static inline functions.
* Most macros become inline helpers. With LiveConnect gone on mozilla-central, we can make the helpers methods of relevant structs or classes finally, instead of static inline functions.
29

edits