473,385 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Private Variable when using Classes

5
Hello,

I have a header file with the following class :
Expand|Select|Wrap|Line Numbers
  1. template<class coord_t, size_t dim, class BTECOLL = BTE_COLLECTION >
  2. class PRtree {
  3.  
  4. typedef AMI_STREAM<box_t> stream_t;
  5.  
  6. private:
  7.  
  8. MORE CLASSES HERE
  9.  
  10. public:
  11.  
  12. MORE CLASSES HERE
  13.  
  14.  
now, when in my c file I try to create this class using:

Expand|Select|Wrap|Line Numbers
  1.  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
Jul 19 '07 #1
2 1185
ravenspoint
111 100+
Hello,

I have a header file with the following class :
Expand|Select|Wrap|Line Numbers
  1. template<class coord_t, size_t dim, class BTECOLL = BTE_COLLECTION >
  2. class PRtree {
  3.  
  4. typedef AMI_STREAM<box_t> stream_t;
  5.  
  6. private:
  7.  
  8. MORE CLASSES HERE
  9.  
  10. public:
  11.  
  12. MORE CLASSES HERE
  13.  
  14.  
now, when in my c file I try to create this class using:

Expand|Select|Wrap|Line Numbers
  1.  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.
Jul 19 '07 #2
algatt
5
Try adding "public:" at line #3.

Attributes of a class are private, by default.
Thanks a lot! It worked!
Jul 19 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Martin Vorbrodt | last post by:
Example code in one of my books intrigues me: class B { public: B* Clone() const { B* p = DoClone(); assert(typeid(*p) == typeid(*this)); return p; }
3
by: jeko | last post by:
Hi, I'm using a class method which read and write on private variable of own class. During the first alghoritm cycle, method read and write correclty on num_elts variable, but during the second...
7
by: Victor | last post by:
I just tried a test comparing a Function to a Private Function with this code: <% Option Explicit dim X1 X1 = 9 Private Function RealTest(here) RealTest = here + X1 End Function
0
by: zman77 | last post by:
EDIT: -- forgot to mention... I am using Visual Studio 2005, on Win XP, on an intel machine Hi. This is my first post, though I've "lurked" for a while because I find these forums very helpful....
17
by: Peng Yu | last post by:
Hi, I'm wondering if there is something in namespace like the 'private' keyword in class? I want to define some class or function that can only be used within that namespace. Thanks, Peng
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.