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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Stupid Compiler Tricks

Stupid Compiler Tricks

Scheduled Pinned Locked Moved C / C++ / MFC
htmlcom
5 Posts 3 Posters 1 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.
  • C Offline
    C Offline
    Cam
    wrote on last edited by
    #1

    File this one under stupid compiler tricks: (there's apparently no html allowed...) http://www.BinaryUprising.com/images/StupidError.JPG rriiiiight..... ;P ~Cam Desautels

    L 1 Reply Last reply
    0
    • C Cam

      File this one under stupid compiler tricks: (there's apparently no html allowed...) http://www.BinaryUprising.com/images/StupidError.JPG rriiiiight..... ;P ~Cam Desautels

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      And I thought "I" had frustrating error messages! Why did that happen, do ya know?

      C 1 Reply Last reply
      0
      • L Lost User

        And I thought "I" had frustrating error messages! Why did that happen, do ya know?

        C Offline
        C Offline
        Cam
        wrote on last edited by
        #3

        Well, (keep in mind I'm pretty new to C++), I was screwing around in Visual Studio trying to learn something (anything). So, I decided to use AppWizard to make a new App, base-ing the view on CTreeView. This is all good and well...so then I decided I'd add something to my fancy new tree. But I needed a pointer to it. So, I did the following:

        GetTreeCtrl()->InsertItem("Hello world")

        And that worked just fine. I did that few times for different items, making some items below others, I changed the background color - I was just learning how the CTreeCtrl works. Anyway, at some point I thought, "Hey, if just stored the address of the Tree in a pointer, I'd save system resources (not to mention typing), by not having to call the GetTreeCtrl() function everytime." So, I wrote the following:

        CTreeCtrl *pOurTree = GetTreeCtrl();

        and it said the following to me:

        cannot convert from 'class CTreeCtrl' to 'class CTreeCtrl *'

        Confused and curious, I said "ok, what the hell, lets see what happens". Removed the asterisk, and compiled again, simply to see what it would say. And that's how I got the error :) . Anyway, I would be curious how to do it correctly. ~Cam Desautels (BinaryUprising.com)

        M 1 Reply Last reply
        0
        • C Cam

          Well, (keep in mind I'm pretty new to C++), I was screwing around in Visual Studio trying to learn something (anything). So, I decided to use AppWizard to make a new App, base-ing the view on CTreeView. This is all good and well...so then I decided I'd add something to my fancy new tree. But I needed a pointer to it. So, I did the following:

          GetTreeCtrl()->InsertItem("Hello world")

          And that worked just fine. I did that few times for different items, making some items below others, I changed the background color - I was just learning how the CTreeCtrl works. Anyway, at some point I thought, "Hey, if just stored the address of the Tree in a pointer, I'd save system resources (not to mention typing), by not having to call the GetTreeCtrl() function everytime." So, I wrote the following:

          CTreeCtrl *pOurTree = GetTreeCtrl();

          and it said the following to me:

          cannot convert from 'class CTreeCtrl' to 'class CTreeCtrl *'

          Confused and curious, I said "ok, what the hell, lets see what happens". Removed the asterisk, and compiled again, simply to see what it would say. And that's how I got the error :) . Anyway, I would be curious how to do it correctly. ~Cam Desautels (BinaryUprising.com)

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

          What's weirder is that "GetTreeCtrl()->InsertItem("Hello world");" even worked. GetTreeCtrl() returns a CTreeCtrl& not a CTreeCtrl*. --Mike-- http://home.inreach.com/mdunn/ "Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001 Sonork - 100.10414 AcidHelm

          C 1 Reply Last reply
          0
          • M Michael Dunn

            What's weirder is that "GetTreeCtrl()->InsertItem("Hello world");" even worked. GetTreeCtrl() returns a CTreeCtrl& not a CTreeCtrl*. --Mike-- http://home.inreach.com/mdunn/ "Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001 Sonork - 100.10414 AcidHelm

            C Offline
            C Offline
            Cam
            wrote on last edited by
            #5

            He, he, he...it's the magic touch of stupidity. You'd be surprized how many ridiculous programming stunts I pull :). It's been a long time since I've programmed in anything that wasn't for the web...I'm very rusty.... ~Cam Desautels (BinaryUprising.com)

            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