S
sharat
hi all
can any body tell how to declare the structure pointer within a class.
i have written the following program but gettin error.
#include<iostream>
using namespace std;
class A
{
public :
struct sample
{
int a ;
int b ;
};
struct sample var1;
struct sample *ptr = &var1;
};
int main()
{
cout<<"\n struct variable ptr prog\n";
}
i m using fc4,gcc compiler.
i m getting the following error.struct.cpp:15: error: 'a::var1'
cannot appear in a constant-expression
struct.cpp:15: error: `&' cannot appear in a constant-expression
struct.cpp:15: error: ISO C++ forbids initialization of member
'ptr'
struct.cpp:15: error: making 'ptr' static
struct.cpp:15: error: invalid in-class initialization of static data
member of non-integral type 'a::sample*'
can any body tell the solution.
thanx in advance.
can any body tell how to declare the structure pointer within a class.
i have written the following program but gettin error.
#include<iostream>
using namespace std;
class A
{
public :
struct sample
{
int a ;
int b ;
};
struct sample var1;
struct sample *ptr = &var1;
};
int main()
{
cout<<"\n struct variable ptr prog\n";
}
i m using fc4,gcc compiler.
i m getting the following error.struct.cpp:15: error: 'a::var1'
cannot appear in a constant-expression
struct.cpp:15: error: `&' cannot appear in a constant-expression
struct.cpp:15: error: ISO C++ forbids initialization of member
'ptr'
struct.cpp:15: error: making 'ptr' static
struct.cpp:15: error: invalid in-class initialization of static data
member of non-integral type 'a::sample*'
can any body tell the solution.
thanx in advance.