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. hi

hi

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 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.
  • G Offline
    G Offline
    gmallax
    wrote on last edited by
    #1

    can we use class1 in class2 without include the class1.h file???

    C A 2 Replies Last reply
    0
    • G gmallax

      can we use class1 in class2 without include the class1.h file???

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      Yes, for example if class1 and class2 are both declared in the same file and class1 is declared before class2. Othwrwise, it depends on what you mean by "use". Next time try a bit more descriptive subject if you post a question, please, "hi" just won't do...

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > Computers are evil, EVIL i tell you!! <

      1 Reply Last reply
      0
      • G gmallax

        can we use class1 in class2 without include the class1.h file???

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

        Hi back, You can refer to a class that hasn't been defined (in simple terms not had it's .h included) but you can't do anything that requires the compiler to know the size or composition of the class. So, without the .h file you can... - declare a reference to an object of the class - declare a pointer to an object of the class - assign pointer to objects of the class You'd be pushed to say that this lot is "using" the class though. What you can't do... - call member functions of the class - do any sort of RTTI (run time type information) - get the size of the class which in turn means you can't create objects of the class Cheers, Ash

        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