Error in Dev C++...

This is a discussion on Error in Dev C++... within the C++ Programming forums, part of the General Programming Boards category; Code: #ifndef SALES_H_ #define SALES_H_ namespace SALES { const int QUARTERS = 4; class Sales { private: double sales[QUARTERS]; double ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    14

    Question Error in Dev C++...

    Code:
    #ifndef SALES_H_
    #define SALES_H_
    
    namespace SALES {
        
        const int QUARTERS = 4;
        class Sales {
            private:
                double sales[QUARTERS];
                double average;
                double max;
                double min;
            public:
                // default constructor
                Sales();
                Sales(const double ar[], int n);
                ~Sales();
                void showsales() const;
        };
    }
    #endif
    I keep getting this error message:
    sales.h `double SALES::Sales::sales[4]' is private

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    That's because it is. You've got the word private right there on the line before. You can't use private members of a class outside the class.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    14
    Quote Originally Posted by tabstop View Post
    That's because it is. You've got the word private right there on the line before. You can't use private members of a class outside the class.
    My thing is the solution code looks the same in terms of the location of the QUARTERS constant.

  4. #4
    Registered User
    Join Date
    Feb 2009
    Posts
    14
    Ok, I got it. The real problem was in main 'sales' instead of 'Sales'...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Whats better, C-Free or Dev C++??
    By i_can_do_this in forum Tech Board
    Replies: 10
    Last Post: 07-07-2006, 04:34 AM
  2. New to Dev C++/<windows.h>...
    By Cilius in forum C++ Programming
    Replies: 3
    Last Post: 02-23-2005, 12:05 AM
  3. Glut and Dev C++, Programs not Quitting?
    By Zeusbwr in forum Game Programming
    Replies: 13
    Last Post: 11-29-2004, 07:43 PM
  4. DEV C++ Limitations?
    By Kirdra in forum Game Programming
    Replies: 3
    Last Post: 09-09-2002, 09:40 PM
  5. Tutorial about Bloodshed Dev!
    By Unregistered in forum C++ Programming
    Replies: 2
    Last Post: 11-13-2001, 06:42 PM

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