code is show error

#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;
}

only in VS2008 not in VS 2003

error :-
error C2248::: ---------cannot access private member declared in class '--------'


I saw that post somewhere just 1 minute ago...
Didn't I just answer this when posted by someone else?
#include <stdio.h>
#include<iostream>
using namespace std;

class CMobileVoice;

class CVoice
{
private:
int a;

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

};

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

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

int main( )
{
CVoice a;
getchar();
return 0;
}
Topic archived. No new replies allowed.