Private Variable when using Classes

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • algatt
    New Member
    • Jul 2007
    • 5

    #1

    Private Variable when using Classes

    Hello,

    I have a header file with the following class :
    Code:
    template<class coord_t, size_t dim, class BTECOLL = BTE_COLLECTION >
    class PRtree {
    
    typedef AMI_STREAM<box_t> stream_t;
    
    private:
    
    MORE CLASSES HERE
    
    public:
    
    MORE CLASSES HERE
    now, when in my c file I try to create this class using:

    Code:
     PRtree<double, 2>::stream_t *s = new PRtree<double, 2>::stream_t(argv[1]);
    the following error message pops up: stream_t is private

    Any help?

    Thanks
  • ravenspoint
    New Member
    • Jul 2007
    • 111

    #2
    Originally posted by algatt
    Hello,

    I have a header file with the following class :
    Code:
    template<class coord_t, size_t dim, class BTECOLL = BTE_COLLECTION >
    class PRtree {
    
    typedef AMI_STREAM<box_t> stream_t;
    
    private:
    
    MORE CLASSES HERE
    
    public:
    
    MORE CLASSES HERE
    now, when in my c file I try to create this class using:

    Code:
     PRtree<double, 2>::stream_t *s = new PRtree<double, 2>::stream_t(argv[1]);
    the following error message pops up: stream_t is private

    Any help?

    Thanks

    Try adding "public:" at line #3.

    Attributes of a class are private, by default.

    Comment

    • algatt
      New Member
      • Jul 2007
      • 5

      #3
      Originally posted by ravenspoint
      Try adding "public:" at line #3.

      Attributes of a class are private, by default.
      Thanks a lot! It worked!

      Comment

      Working...