Computing.Net > Forums > Programming > VC++ 6 problem with friend function

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VC++ 6 problem with friend function

Reply to Message Icon

Name: carl2003
Date: February 19, 2003 at 22:11:03 Pacific
OS: win XP
CPU/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.




Sponsored Link
Ads by Google

Response Number 1
Name: borelli34
Date: February 19, 2003 at 22:52:26 Pacific
Reply:

Is the friend specifier within the class definition or within an inherited instantiation?

borelli34


0

Response Number 2
Name: carl2003
Date: February 19, 2003 at 23:41:05 Pacific
Reply:

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 ..


0

Response Number 3
Name: Mathew Joy
Date: February 19, 2003 at 23:49:24 Pacific
Reply:

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.


0

Response Number 4
Name: carl2003
Date: February 20, 2003 at 00:18:22 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







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


Sponsored links

Ads by Google


Results for: VC++ 6 problem with friend function

problem with date() function in PHP www.computing.net/answers/programming/problem-with-date-function-in-php/8855.html

Linker-Problem wit VC++ 6 MFC and M www.computing.net/answers/programming/linkerproblem-wit-vc-6-mfc-and-m/3496.html

VC++6 Customizing Woes -- Help!! www.computing.net/answers/programming/vc6-customizing-woes-help/733.html