Topic: Question about "C" struct and "C++" class


Author: suleman@netcom.com (Dani Suleman)
Date: Mon, 8 Nov 1993 06:59:44 GMT
Raw View
     Hi,
     I'm new in C++, I have a question here about C++, here's
     what I wanna do and in "C":

     typedef stuct Rect{
        int left, top, right, bottom;
     } Rect;
     typedef char * string;
     typedef struct object {
        Rect a;
        string b;
     }object;

     object     obArray[2] = {  {(1, 2, 3, 4), "abc"},
                                {(2, 3, 5, 7), "cdg"}};

     How do you do this in C++ ? I've managed to reach this:

     class CRect{
     private:
        int left, top, right, bottom;
     public:
        CRect(int, int, int, int);
        // ....some accessing functions
     };

     class CObject{
     private:
        CRect a;
        CString b;
     public:
        CObject(CRect rect, CString string);
     };

     class CObArray{
     private:
        CObject * obs;
     public:
        CObArray(.....); ???
     }

     Now, how do I initialize this class to contain a set of fixed
     data in a fixed size array ?
     I'd appreciate if you can direct all your replies to my account.

     --dani

--
--dani
suleman@netcom.com <-- use only if you think the content is highly
   private & confidential and concerns my sex life :)
DSuleman@caere.com <--  prefered if you feel I'll be safe even if my
   employer is spying on my e-mail :)