On May 4, 9:25 am, aki <akhileshrawat...@gmail.comwrote:
On May 4, 11:38 am, sam_...@yahoo.co.in wrote:
On May 4, 10:59 am, aki <akhileshrawat...@gmail.comwrote:
//defined in header file
struct authProt
{
uint8_t type;
uint8_t length;
uint16_t authprot;
};
//in main file
authProt ap;
----
----
memberfun();
// In memberfunc()
ap.type=1; // there is segmentaion fault here i do not know why?
any comments please?
you have just declared the object, have you allocated space for the
same with new operator?
do i need separate memory allocation..
if i am right ... memory for object is created when its declared...
When it is defined, not just declared.
Regretfully, you don't provide enough context for me to really
say anything. If "authProt ap;" is in global scope, it is a
definition, and there shouldn't be any problem. You speak of
"memberfunc()", however: member of what? And where is ap
defined, and how is memberfunc called?
--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34