Thread: Accessing data declared private within header file

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    7

    Accessing data declared private within header file

    I have a header file that declares some fields as private, I then have a class that I need to compare two of the objects' information for equality but neither of them are the calling objects. I cannot alter the header file. How would I go about comparing private data fields? I will enter a brief bit of code for clarity.
    Thank You.

    Code:
    // Header File
    // stuff.h
    
    class stuff
    {
    private: 
      int* arr[20];
      int size;
    };
    bool equal (const stuff& a, const stuff& b);
    
    
    
    // Class File
    // stuff.cpp
    
    #include "stuff.h"
      
    stuff::stuff() 
    {
      size = 0;
    }
    
    bool equal  (const stuff& a, const stuff& b)
    {
    /* 
    Where I cannot figure out how to compare the two objects for equality due to private fields in the header 
    */
    }
    Last edited by googol; 02-10-2015 at 05:25 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 04-05-2014, 09:23 PM
  2. Accessing private Data members
    By Emeighty in forum C++ Programming
    Replies: 17
    Last Post: 08-14-2008, 11:16 PM
  3. Question with accessing private data
    By mikahell in forum C++ Programming
    Replies: 3
    Last Post: 01-18-2008, 03:14 AM
  4. Replies: 30
    Last Post: 06-19-2006, 12:35 AM
  5. Accessing private data members
    By maloy in forum C++ Programming
    Replies: 11
    Last Post: 10-04-2002, 02:48 PM

Tags for this Thread