3

Possible Duplicate:
Class names that start with C.

I am a newbie using c++ and people named c++ class name "c"+something. What does that mean? I think this is a syntax but don't know what it means..

Community
  • 1
  • 1
codereviewanskquestions
  • 13,460
  • 29
  • 98
  • 167
  • 4
    because c is for cookie. (and that's good enough for me) – madmik3 Jun 14 '11 at 02:05
  • Convention only - another is to use underscore_t for types (maybe including classes), as with some standard types such as `std::size_t`. –  Jun 14 '11 at 02:06
  • 1
    See the other comment and answers below. The Borland tools used "T" (presumably for "type) rather than "C". It's interesting to me that "I" is still used as a prefix to denote interfaces in .NET today. – David Jun 14 '11 at 02:08
  • 1
    @Steve314 - the _t comes from C and I believe it's supposed to denote `typedef`s. – David Jun 14 '11 at 02:10
  • @David: the `_t` is reserved for POSIX typedefs, and is best avoided in other C and C++ usage. – Tony Delroy Jun 14 '11 at 03:34
  • @Tony - The C++ standard doesn't reserve anything for Posix AFAIK ;-) - seriously, _t used in the C++ standard library which is not Posix - "best avoided" can't be that strict. And a lot of C++ programmers have never programmed for Posix, and have no reason to know anything about it. –  Jun 14 '11 at 17:04
  • @David - Interesting point, but the problem with easily misunderstood conventions (ie my excuse) is that they can easily trigger alternative conventions consistent with the misunderstanding. Also (my second excuse), _t is found as a convention for types in some non-C-family languages. I probably saw it in Pascal first, which IIRC doesn't have any type alias declarations. I've certainly seen it in Ada. –  Jun 14 '11 at 17:08

2 Answers2

9

you don't. it's a naming convention only: http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices (see Hungarian)

jcomeau_ictx
  • 37,688
  • 6
  • 92
  • 107
8

It's not needed by C++, but some people do it to remind them that the identifier is for a class. It's considered bad practice now, but was popular (especially in Microsoft environments) a decade or more ago.

Tony Delroy
  • 102,968
  • 15
  • 177
  • 252