Pointer to class

This is a discussion on Pointer to class within the C++ Programming forums, part of the General Programming Boards category; Hello, I need interaction between classes and I do it this way: Code: class tcp_packet { private: public: int *from; ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    69

    Pointer to class

    Hello, I need interaction between classes and I do it this way:

    Code:
    class tcp_packet
    {
        private:
    
        public:
            int *from;
        .....
    };
    
    class con_client
    {
        private :
            int sock;
        public :
            DWORD ServeClient();
            ....
    };
    
    ........
    
    DWORD con_client::ServeClient()
    {
    ...
    cResult =  recv(this->sock, (char*)RecPck.buff, 1024, 0);
            if (cResult > 0)
            {
                RecPck.size = cResult;
                RecPck.from = (int*)this;
            }
    ...
    }
    
    void tcp_packet_s_handler::read_Login(tcp_packet pck)
    {
        con_client *c;
        c = (con_client*)pck.from;
    }
    But it doesnt work, whats wrong there?

  2. #2
    3735928559
    Join Date
    Mar 2008
    Location
    RTP
    Posts
    839
    how do you propose to convert the data in that packet into an address of an instance of your con client class?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. base class pointer pointing at derived class
    By mynickmynick in forum C++ Programming
    Replies: 11
    Last Post: 12-01-2008, 12:26 PM
  2. Base-class pointer, accessing object from derived class
    By Korhedron in forum C++ Programming
    Replies: 15
    Last Post: 09-28-2008, 06:30 AM
  3. Replies: 25
    Last Post: 10-29-2007, 05:08 PM
  4. finding derived class type of a pointer to a base class
    By LinuxCoder in forum C++ Programming
    Replies: 15
    Last Post: 04-10-2006, 12:08 PM
  5. base class pointer to derived class objects
    By curlious in forum C++ Programming
    Replies: 4
    Last Post: 09-28-2003, 09:39 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21