Problem with structure and class
Hi !
Can I declare structure inside class and return pointer to structure.........
like this.......
//xml.h
struct line
{
int width;
int color;
int length;
};
class XML
{
public:
line* read(char* filepath);
int m_width,m_color,m_length;
};
[/code]
Implementation of XML file.........
Code:
line* Xml::read(char* filepath)
{
line *m_line;
//some operation of parsing file
m_line->width=m_width;
m_line->color=m_color;
m_line->length=m_length;
return line;
}
And this function ic called from fileParser.cpp
Code:
Xml *xml=new Xml();
line *m_line;
m_line=xml->read(filepath);
cout<<m_line->width<<line_color<<line_length;
}
It is compiling but giving segmentation fault.
Can any body tell me that where is problem........or should I change implementation..
Thanks