VS2008 Problem in pise of code

This Small pice of code this is rum in VS2003 but not in VS2008
result on VS 2003 :- call the constructor.

i got this error on VS 2008 "error C2248: 'CVoice::getdata' : cannot access private member declared in class 'CVoice'"

How to reslove this Issue ?

#include "stdafx.h"
using namespace std;

class CMobileVoice;

class CVoice
{
private:
int a;
int getdata();
public:
CVoice()
{
getdata();
std::cout<<"constructor";
a=10;
}

};

int CVoice::getdata()
{
return 100;
}

class CMobileVoice
{
public:
friend int CVoice::getdata();
};

int _tmain(int argc, _TCHAR* argv[])
{
CVoice a;
getch();
return 0;
}

Friends again? Any chance of formatting your code next time?

class CMobileVoice
{
public:
friend int CVoice::getdata();
};

Should be:
1
2
3
4
class CMobileVoice
{
friend CVoice;
};
read this in addition, everything what you need (and what will clarify @kbw's post) is here:
http://www.cplusplus.com/doc/tutorial/inheritance/
Topic archived. No new replies allowed.