Thread: Class questions!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    51

    Class questions!

    I just have a couple questions concerning classes.

    1. Can you have multiple classes in one file? as in #ifndef...#endif then another #ifndef...

    2. does the file name have to be the same as the class name? aka circle.h and the file has to be circle?

    3. Do classes only handle data? Can the member functions cout stuff to the screen and get input?

    4.What exactly does a constructor do? Like lets say you want to house a constructor for a house, would you have to set all the variables there to zero

    Code:
    public:
    house();
    
    private:
    float doors, windows, rooms;
    
    house::house()
    {
    doors=0;
    windows=0;
    rooms=0;
    }
    5. Can someone please explain to me what this "copy constructor" does because I have no clue on that

    Code:
    public:
              circle();
              circle(const circle &);<-copy constructor
    private:
              ....
    
    circle::circle(const circle & Object)<-Dont know what object exactly does
    {
    radius=object.radius;
    }
    Tell me if you need the entire coding for the copy constructor but yea thanks for reading all my questions
    Last edited by Shadowwoelf; 01-19-2007 at 07:16 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class design problem
    By h3ro in forum C++ Programming
    Replies: 10
    Last Post: 12-19-2008, 09:10 AM
  2. Replies: 8
    Last Post: 10-02-2005, 12:27 AM
  3. Class Questions
    By shane1985 in forum C++ Programming
    Replies: 7
    Last Post: 10-29-2003, 10:34 AM
  4. Series of class questions #1
    By kippwinger in forum C++ Programming
    Replies: 4
    Last Post: 10-02-2003, 04:28 AM
  5. class member access denied
    By chiqui in forum C++ Programming
    Replies: 2
    Last Post: 05-27-2002, 02:02 PM