Passing pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stinger5900
    New Member
    • Feb 2008
    • 4

    #1

    Passing pointers

    First of all I am new to C++.
    I have created a class, lets say class A. When the constructor is called I create two new classes Class B and Class C, then are not the same class as A.

    I need to get data from class B into Class C. How should I go about this? I though I could make a function in class A that returns the data, but how do I get a pointer of Class A into Class B so I can access the data from class A Since Class B is created during the constructor their is no way of passing a pointer of Class A to it.
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    Let's back up a minute.

    First, you declare a class.

    Second, you define a object of the class. Here the compiler will use your class declaration to allocate memory for your data members and will call your constructor top initialize those data members.

    Third, you now have an object of class A so I don't know what you mean by "When the constructor is called I create two new classes Class B and Class C, then are not the same class as A."

    Maybe you could clear up my confusion and then we can go from there.

    Comment

    Working...