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. Strange kind of class

Strange kind of class

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
4 Posts 3 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.
  • A Offline
    A Offline
    Ahmad
    wrote on last edited by
    #1

    HI Strange kind of class Some times I see this class like below : LINE 1 : class CImage; LINE 2 : class CTestpicDlg : public CDialog LINE 3 : { LINE 4 : // Construction LINE 5 : public: LINE 6 : void draw(); LINE 7 : CImage *image; LINE 8 : CTestpicDlg(CWnd* pParent = NULL); // standard constructor LINE 9 : } So my question is about two thing's : 1- (CImage)class ,it hasn't any braces and !!! 2- The (CImage)class defined in cimage.lib which I append it in my project so why I must write LINE 1, if I omit this line I get alot of errors like : error C2143: syntax error : missing ';' before '*' error C2501: 'CImage' : missing storage-class or type specifiers Thank you ... AHMAD ALWASHALI

    L 1 Reply Last reply
    0
    • A Ahmad

      HI Strange kind of class Some times I see this class like below : LINE 1 : class CImage; LINE 2 : class CTestpicDlg : public CDialog LINE 3 : { LINE 4 : // Construction LINE 5 : public: LINE 6 : void draw(); LINE 7 : CImage *image; LINE 8 : CTestpicDlg(CWnd* pParent = NULL); // standard constructor LINE 9 : } So my question is about two thing's : 1- (CImage)class ,it hasn't any braces and !!! 2- The (CImage)class defined in cimage.lib which I append it in my project so why I must write LINE 1, if I omit this line I get alot of errors like : error C2143: syntax error : missing ';' before '*' error C2501: 'CImage' : missing storage-class or type specifiers Thank you ... AHMAD ALWASHALI

      L Offline
      L Offline
      l a u r e n
      wrote on last edited by
      #2

      LINE 1: Class CImage; is a forward reference to another class that lets the CTestPicDlg class know what to do with the LINE 7: CImage *image ptr type ... excluding LINE 1: gives compile errors cos the compiler then doesnt know what CImage is :) --- "every year we invent better idiot proof systems and every year they invent better idiots"

      A 1 Reply Last reply
      0
      • L l a u r e n

        LINE 1: Class CImage; is a forward reference to another class that lets the CTestPicDlg class know what to do with the LINE 7: CImage *image ptr type ... excluding LINE 1: gives compile errors cos the compiler then doesnt know what CImage is :) --- "every year we invent better idiot proof systems and every year they invent better idiots"

        A Offline
        A Offline
        Ahmad
        wrote on last edited by
        #3

        Thank you lauren but (CImage)class defined in cimage.lib which I append it in my project can you tell me please AHMAD ALWASHALI

        M 1 Reply Last reply
        0
        • A Ahmad

          Thank you lauren but (CImage)class defined in cimage.lib which I append it in my project can you tell me please AHMAD ALWASHALI

          M Offline
          M Offline
          markkuk
          wrote on last edited by
          #4

          The compiler can't know anything about classes inside .lib files, they are only used in the link phase. The CImage class must be declared in a source file (.cpp or .h) so that the compiler can see it.

          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