Hello everyone,i wrote the following code where there is a function which ads two object of class type.In order to have acess in the private members of the class objects i declared my function as "friend".I try to compile it in visual studio 2006 but i have this "fatal error C1001: INTERNAL COMPILER ERROR".I tested in g++ in Ubuntu and it runs just fine! Does anyone knows what is going on?
#include<iostream>
usingnamespace std;
class one
{
public:
one(){};
one(int k,int l){a=k;b=l;}
void print(){int w=a;int e=b;cout<<"a is "<<w<<",b is "<<e<<endl;}
private:
int a,b;
friend one operator+(const one ena,const one dyo);
};
one operator+(const one ena,const one dyo)
{
return one((ena.a+dyo.a),(ena.b+dyo.b));
}
int main()
{
one n1,n2(2,2),n3(7,3);
n1=n2+n3;
n1.print();
return 0;
}
note:The compile error starts only when i declare my overload operator + as friend.Thanks!
There is a big difference between Visual Studio 2006 (does it even exist?) and Visual C++ 6.0 and yes, it's definitely too old.
That doesn't have anything to do with the operating system, though.