How to access member of a class from a diff class

Home Forums C Programming How to access member of a class from a diff class

Viewing 0 reply threads
  • Author
    Posts
    • #2077
      cheeranjiv
      Participant

      Hi ,
      I am a beginner in C++.
      I want to know how can we access data member of a class from another class. I am facing problem in visualizing the things in writing separate .h and .cpp file.
      Here I explain the things.We have three classes.
      In a.cpp (assuming the a.h files is wriiten )

      In b.h

      In b.cpp

      How to go about it ?
      If declare a member of type B in our C class..it will carete another instance of B but does not contains the data in the live B object.
      Is passing a reference to the B class in the contructor of C class is asolution? If so, whow to do that. I am getting confused in implementin this concept.
      And what other ways are there?

      Thanks and regards,
      Alex

Viewing 0 reply threads
  • You must be logged in to reply to this topic.
Share
Tweet
Share
Pin