| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
class a
{ public: int status; void mfunc1(); void mfunc2(); } void a::mfunc1() { status=true; } void a::mfunc2() { mfunc1(); if(status==true) <....................................... after it executes mfunc1 ; status become inaccessible and i get segmentation fault in gdb /......why? { .... .................... } } main() { a *ptr; ptr=new a(); ptr->mfunc2; } |
|
#2
|
|||
|
|||
|
you need a semicolon after class declarations:
Code:
class a {
...
}; //<----note the semicolon
also, to call a function without any parameters you still need to include empty parentheses: Code:
... ptr->mfunc1(); //<----note the parentheses () ... i don't know where the segmentation fault came from--for me, until I made those changes it wouldn't compile (dev-c++ 4.9.9.2) |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > segmentation fault after returning from member function |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|