Struct inside a class
Posted
by Balakrishnan
on Stack Overflow
See other posts from Stack Overflow
or by Balakrishnan
Published on 2010-06-09T17:08:52Z
Indexed on
2010/06/09
17:12 UTC
Read the original article
Hit count: 151
c++
I have a class definition of the form
class X
{
public:
//class functions
private:
A_type *A;
//other class variables
};
and struct A_type is defined as
struct A_type
{
string s1,s2,s3;
};
Inside the constructor, I allocate appropriate memory for A and try A[0].s1="somestring"; It shows segmentation fault. Is this kind of declaration invalid, or am I missing something
© Stack Overflow or respective owner