Nested Class Object Return

Class A
{
public x;
class B
{
public:
int Y
B search(int tempx,int tempy)//not constuctor its memberfunction
};
B ObjB[25];TempB
};
B A::B::search(int PId,int SId)
{
A obj
int i;
fstrean AFile("A.dat",ios::in | ios::binary);
while(A.read((char *)&TempProduct,sizeof(Product)))
{
if(A.x==tempx)
{
for(i=0;i<25;i++)
{


if(A.B[i].Y=tempy)
{

A.TempB=A.B[i];
}
}
}
}
return (A.TempB);
AFile.close();
}

i want the value of class B as return type but i got error as following
1)syntax error : missing ';' before 'tag::id'
2)'B' : missing storage-class or type specifiers
3)unexpected end of file found
my main problem is how to return class b data with main function

Please reply as fast as possible




Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
struct A
{
    // ,,,

    struct B
    {
        int a ;
        int b ;
        // ...
        B foo( int x, int y  ) const ;
    };

    // ,,,
    B its_b_object { 10, 20 };
};

A::B A::B::foo( int x, int y  ) const { return B { a+x+y, b-x-y } ; }

int main()
{
    A some_a ;
    A::B object = some_a.its_b_object.foo( 1, 2 ) ;
    // use object
}
Topic archived. No new replies allowed.