Pointer problem

This is a discussion on Pointer problem within the C++ Programming forums, part of the General Programming Boards category; so I have Code: class A{ public: draw(){ cout<<"hello"; } } class B{ A* pA; friend class C; } class ...

  1. #1
    Registered User
    Join Date
    Jun 2011
    Posts
    51

    Pointer problem

    so I have
    Code:
    class A{
    
    public:
    draw(){
    cout<<"hello";
    }
    }
    
    class B{
    A* pA;
    
    friend class C;
    }
    
    
    class C{
    B* pB;
    
    }
    I want to use pC to call the draw() function in A.
    I used this pB->pA->draw(); but it doesnt seem to work.

    Did I call it correctly?
    Last edited by byebyebyezzz; 12-06-2011 at 04:41 PM.

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    but it doesnt seem to work.
    This is a very vague statement. Computers aren't vague - and if you want help using them, you can't be either. Please post the specific error message you get, or the specific behaviour that you (i) get and (ii) expect to get.

  3. #3
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,768
    Also indent properly and give us some working code (the above won't compile). Also, there is no pC in your code.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with pointer to a pointer variable
    By Rodri in forum C Programming
    Replies: 2
    Last Post: 11-20-2011, 09:50 AM
  2. pointer to pointer realloc problem
    By prakash0104 in forum C Programming
    Replies: 14
    Last Post: 04-06-2009, 08:53 PM
  3. sturct/pointer problem, and fscanf problem
    By hiphop4reel in forum C Programming
    Replies: 6
    Last Post: 07-28-2008, 09:40 AM
  4. Replies: 4
    Last Post: 11-05-2006, 01:57 PM
  5. pointer to pointer how do i solve following problem?
    By kobra_swe in forum C Programming
    Replies: 5
    Last Post: 07-19-2006, 04:49 PM

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