Results 1 to 16 of 16

Thread: [Resolved] Classes and Destructors

Threaded View

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] Classes and Destructors

    I've never officially learned about classes, I just use them all the time but never really understand them. So a few questions:

    1) What is the purpose of the desctructor? Does it just clear up memory?

    2) What's wrong with this?:

    Code:
    class square_info {
        private:
            float h, w;
    
    
        public:
            square_info () {
                h = 0;
                w = 0;
            }
    
            square_info (float height, float width) {
                h = height;
                w = width;
            }
    
            void print() {
                cout << "h: " << h << " | w: " << w << endl;
            }
    
            ~square_info(); //adding this line gives linking errors?
    };
    Thanks in advance.
    Last edited by The Hobo; Nov 7th, 2002 at 02:30 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width