CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: C++ class

  1. #1
    Join Date
    May 1999
    Posts
    19

    C++ class

    I have a problem with classes of c++;
    eg.

    typedef struct tag{
    char *ppp;
    }X;

    class Y
    {
    X *exx;
    char *yyy;
    };

    i want to access members of X through Y
    eg. Y *yyy;
    now i want to access ppp , how do i access it?or how do i make a pointer to X?
    Fast reply appreciated
    Tapan



  2. #2
    Guest

    Re: C++ class

    First of all, you must create an instance of class Y
    Y *yyy = new Y;
    Now, you must connect member pointer 'exx' to real object of type X, i.e.
    yyy->exx = new X;
    And now, you must connect member pointer 'ppp' to real data
    yyy->exx->ppp = new char[16];
    strcpy(yyy->exx->ppp, "BlahBlahBlah");
    Hope this helps. If not, or you have any questions, write me to [email protected]
    (Sorry for my bad english)


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

Featured