| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
VC++ 6 problem with friend function
|
Original Message
|
Name: carl2003
Date: February 19, 2003 at 22:11:03 Pacific
Subject: VC++ 6 problem with friend functionOS: win XPCPU/Ram: 256 |
Comment: Hi there, I currently started using vc++, the problem with VC++ 6.0 is when i try to access data members by friend function i get a massage.. ""cannot access private member declared in class..." When usind bloodshed , i dont get this message and everything works fine.. What would be the problem with VC++? I appreciate any help.. Thanks in advance.. Carl.
Report Offensive Message For Removal
|
|
Response Number 1
|
Name: borelli34
Date: February 19, 2003 at 22:52:26 Pacific
|
Reply: (edit)Is the friend specifier within the class definition or within an inherited instantiation? borelli34
Report Offensive Follow Up For Removal
|
|
Response Number 2
|
Name: carl2003
Date: February 19, 2003 at 23:41:05 Pacific
|
Reply: (edit)Its within the class definittion.. I just made a little reasearch and i found out that VC++ has a liitle bug when using namespace std; with friend functions.. Now i am trying to download the upgrate package and hopefully i will make it work.. Here is a link with a description about this "bug".. http://www.cs.virginia.edu/~csadmin/pc/pclabs/vc_faq/ just screw down and you will see.. also information on upgrading... Thanks ..
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: Mathew Joy
Date: February 19, 2003 at 23:49:24 Pacific
|
Reply: (edit)Dear Carl, Normally u won't get such an error. The friend keyword must me specified at the delaration inside the class, not at the definition. And also note that the friend function cannot access the private members of the base class if it is a friend of the derived class.
Report Offensive Follow Up For Removal
|
|
Response Number 4
|
Name: carl2003
Date: February 20, 2003 at 00:18:22 Pacific
|
Reply: (edit)Ok ..maibe i was wrong when i said deffiniton...My program actually is quite simpe-i dont have derived classes..Its a just a simple class with three priavet data members-gpa,id,name..some functions and a a few friend functions as public within the class. I compiled with bloodshed and it wordked , but with VC++ it didnt work and i kept getting that error message that i dont have permission to access the data members.. But after i downloaded and upgraded from the link which i specified above it seems like it works.. I am pretty sure something was wrong with the microsoft compieler... But thanks to all of you..:-) Carl
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Programming Forum Home