class type help

This is a discussion on class type help within the C++ Programming forums, part of the General Programming Boards category; Hi everyone, I got problem understanding classes in C++. I hope some one would help me with this. Lets say ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    2

    Unhappy class type help

    Hi everyone,

    I got problem understanding classes in C++. I hope some one would help me with this.
    Lets say I have x.h file where class x is declared with its private and public members. Also I have x.cpp file where the body of each function from class x is located.
    I have another y.h and y.cpp file done the same way as previous.
    Also I have main.cpp file that contains main function.

    I have to create z.h file and z.cpp file that contains z class. This class will have its private and public members as well.
    Now, because members in calss x and class y should not be change at any time plus private members from class z should not be change I have to come up with the way how to use them. I have to come up with functions in calss z that would get members from thiferent classes and private members from z calss.

    It shouls look something like this
    Code:
     class z {
    
    int a;
    int b;
    
    public:
    
    z ();
    void someFunctions();
    
    int geta() { return a;}
    int getb() {return b;}
    }
    I guess this is how would I get private parts from same class without changing them. But I dont understand how can I get members from other classes (class x and y). It has to be part of class z and it would be something like x & getx();
    and y & gety();

    I would apritiated if anyone can help me with this. If you need more information about what I'm talking about let me know I will try to go in more details.
    I'm tring to understand the consept of this.

  2. #2
    Registered User
    Join Date
    Nov 2009
    Posts
    2
    There has to be someone that knows about classes
    Please help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 09:18 PM
  2. Question on l-values.
    By Hulag in forum C++ Programming
    Replies: 6
    Last Post: 10-13-2005, 05:33 PM
  3. Erros in Utility Header File
    By silk.odyssey in forum C++ Programming
    Replies: 4
    Last Post: 12-22-2003, 06:17 AM
  4. class errors
    By romeoz in forum C++ Programming
    Replies: 3
    Last Post: 09-16-2003, 08:57 PM
  5. Warnings, warnings, warnings?
    By spentdome in forum C Programming
    Replies: 25
    Last Post: 05-27-2002, 07:49 PM

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