Thread: what is : operator ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    92
    exactly i was talking about that.

    The colon simply says that what follows will be an initialization list followed by the constructor
    not clear.

    what is the equivalent code of that ?
    your brackets are not properly written probabily
    blue_gene

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >what is the equivalent code of that ?
    In this case:
    Code:
    myClass::myClass ( int a, int b, int c )
    {
      mya = a;
      myb = b;
      myc = c;
    }
    >your brackets are not properly written probabily
    ...
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    92
    yes,latter one i know and that is very simple . i also read about initialization list from my book.

    i wonder, how many ways a simple thing can be made complicated !! there are many syntaxes for the same thing!!

    anyway, its fine....ok

    thanks
    blue_gene

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >how many ways a simple thing can be made complicated !!
    You really don't want to know.

    >there are many syntaxes for the same thing!!
    Well, when it comes to initialization lists, there is a purpose. Create a class with a const or reference member and see how far you get trying to initialize it in the constructor body.
    My best code is written with the delete key.

  5. #5
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    You all forgot about when using switches

    Code:
    switch(variable) {
         case something:
              statement;
              break;
    etc.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

  6. #6
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >You all forgot about when using switches
    >>but : is used elsewhere (bit fields, inheritance, labels)
    My best code is written with the delete key.

  7. #7
    Obsessed with C chrismiceli's Avatar
    Join Date
    Jan 2003
    Posts
    501
    You caught me prelude, I forgot about labels and bitfields, haven't done too much with inheritence yet, I still am learning c++. I guess the : operator is the misc. operator. Do all know all operator.
    Help populate a c/c++ help irc channel
    server: irc://irc.efnet.net
    channel: #c

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Failure to overload operator delete
    By Elysia in forum C++ Programming
    Replies: 16
    Last Post: 07-10-2008, 01:23 PM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. Operator Overloading (Bug, or error in code?)
    By QuietWhistler in forum C++ Programming
    Replies: 2
    Last Post: 01-25-2006, 08:38 AM
  5. operator overloading and dynamic memory program
    By jlmac2001 in forum C++ Programming
    Replies: 3
    Last Post: 04-06-2003, 11:51 PM