C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 27th, 2004, 05:07 AM
bbramya bbramya is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 3 bbramya User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Exclamation segmentation fault after returning from member function

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;
}




Reply With Quote
  #2  
Old March 24th, 2005, 08:28 PM
ubergeek ubergeek is offline
Contributing User
Dev Articles Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 ubergeek User rank is Private First Class (20 - 50 Reputation Level)ubergeek User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 2 Days 22 h 40 m 27 sec
Reputation Power: 4
Send a message via AIM to ubergeek
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)

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > segmentation fault after returning from member function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT