Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Is this standard?

Is this standard?

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jawache
    wrote on last edited by
    #1

    I've just seen this in some code (CLabel from CodeProject).... i've nver seen syntax like this before but it works!!

    m\_monty
    	.SetFontName("Arial")
    	.SetFontSize(12)
    	.SetTextColor(RGB(255,255,0))
    	.SetFontUnderline(TRUE)
    	.SetBkColor(RGB(0,0,0))
    	.SetFontItalic(TRUE)
    	.SetFontBold(TRUE)
    	.SetBorder(TRUE)
    	.SetSunken(TRUE);
    

    is this standard C++ or just a vc++ thing? Asim Hussain e: asim@jawache.net w: www.jawache.net

    D P J M 4 Replies Last reply
    0
    • J Jawache

      I've just seen this in some code (CLabel from CodeProject).... i've nver seen syntax like this before but it works!!

      m\_monty
      	.SetFontName("Arial")
      	.SetFontSize(12)
      	.SetTextColor(RGB(255,255,0))
      	.SetFontUnderline(TRUE)
      	.SetBkColor(RGB(0,0,0))
      	.SetFontItalic(TRUE)
      	.SetFontBold(TRUE)
      	.SetBorder(TRUE)
      	.SetSunken(TRUE);
      

      is this standard C++ or just a vc++ thing? Asim Hussain e: asim@jawache.net w: www.jawache.net

      D Offline
      D Offline
      dabs
      wrote on last edited by
      #2

      My guess is that these functions in the CLabel class return a CLabel& . That way you can chain many function calls together in one line (or many lines for that matter). It could also be written as: m_monty.SetFontName("Arial").SetFontSize(12).SetTextColor( etc )...


      Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!

      1 Reply Last reply
      0
      • J Jawache

        I've just seen this in some code (CLabel from CodeProject).... i've nver seen syntax like this before but it works!!

        m\_monty
        	.SetFontName("Arial")
        	.SetFontSize(12)
        	.SetTextColor(RGB(255,255,0))
        	.SetFontUnderline(TRUE)
        	.SetBkColor(RGB(0,0,0))
        	.SetFontItalic(TRUE)
        	.SetFontBold(TRUE)
        	.SetBorder(TRUE)
        	.SetSunken(TRUE);
        

        is this standard C++ or just a vc++ thing? Asim Hussain e: asim@jawache.net w: www.jawache.net

        P Offline
        P Offline
        Pavel Klocek
        wrote on last edited by
        #3

        Yes it's standard. The methods return a reference to an instance of the class. Pavel Sonork 100.15206

        J 1 Reply Last reply
        0
        • P Pavel Klocek

          Yes it's standard. The methods return a reference to an instance of the class. Pavel Sonork 100.15206

          J Offline
          J Offline
          Jawache
          wrote on last edited by
          #4

          Ahhhh...... :-O Asim Hussain e: asim@jawache.net w: www.jawache.net

          1 Reply Last reply
          0
          • J Jawache

            I've just seen this in some code (CLabel from CodeProject).... i've nver seen syntax like this before but it works!!

            m\_monty
            	.SetFontName("Arial")
            	.SetFontSize(12)
            	.SetTextColor(RGB(255,255,0))
            	.SetFontUnderline(TRUE)
            	.SetBkColor(RGB(0,0,0))
            	.SetFontItalic(TRUE)
            	.SetFontBold(TRUE)
            	.SetBorder(TRUE)
            	.SetSunken(TRUE);
            

            is this standard C++ or just a vc++ thing? Asim Hussain e: asim@jawache.net w: www.jawache.net

            J Offline
            J Offline
            Jim A Johnson
            wrote on last edited by
            #5

            This is not the least bit standard. It's the result of someone trying to be cute. Certainly it works - see the other responses for why - but it's pointless.

            1 Reply Last reply
            0
            • J Jawache

              I've just seen this in some code (CLabel from CodeProject).... i've nver seen syntax like this before but it works!!

              m\_monty
              	.SetFontName("Arial")
              	.SetFontSize(12)
              	.SetTextColor(RGB(255,255,0))
              	.SetFontUnderline(TRUE)
              	.SetBkColor(RGB(0,0,0))
              	.SetFontItalic(TRUE)
              	.SetFontBold(TRUE)
              	.SetBorder(TRUE)
              	.SetSunken(TRUE);
              

              is this standard C++ or just a vc++ thing? Asim Hussain e: asim@jawache.net w: www.jawache.net

              M Offline
              M Offline
              Michael Dunn
              wrote on last edited by
              #6

              It's "cute" coding following the style of STL streams, where you can chain a lot of stuff together like:

              cout << "Hello " << "Bob" << endl;

              --Mike-- "I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups