Program 1:
#include "stdafx.h"
#include
using namespace std;
class Alpha;
typedef Alpha Constructor ;
class Beta
{
public:
Beta(){;}
private:
int nVal;
friend class Constructor;
};
class Alpha
{
private:
public:
Alpha() {;}
};
int main()
{
Alpha obj1;
Beta obj2;
return 0;
}
Again if the private data of class Beta is accessed by class data, a compile time error is generated regarding access of private data. Here also error must be usage of typedef name in a place where elaborated-type-specifier must be used. Program 2 given below demonstrates this issue.
Program 2
using namespace std;
class Alpha;
typedef Alpha Constructor ;
class Beta
{
private:
int nVal;
friend class Constructor;
};
class Alpha
{
private:
Beta obj;
public:
Alpha::Alpha()
{
obj.nVal = 10;
cout<<"Constructor\n";
}
};
int main()
{
Alpha obj1;
return 0;
}
Microsoft Comment
Thanks for your feedback. We have tried to reproduce the issue with the latest Visual Studio build (Orcas Beta 1) (http://www.microsoft.com/downloads/details.aspx?FamilyId=36B6609E-6F3D-40F4-8C7D-AD111679D8DC&displaylang=en) and we cannot reproduce it. It is likely a known issue fixed in the latest build. If the issue is critical to you with the release of Visual Studio you are working with, you may contact our Product Support Services (http://support.microsoft.com). Our dedicated Support Engineer will work with you to investigate to issue further.
1 comment:
if u remove the "class" keyword before the Constructor , in class Beta , i think i will compile
like "friend Constructor;"
Anyway still bug is there..
Post a Comment