By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,193 Members | 843 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,193 IT Pros & Developers. It's quick & easy.

segmentation fault on private variable

P: n/a
Hi,
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

thanks

Andrea
Nov 14 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
jeko wrote:
Hi,
I'm using a class method which read and write on private variable of own
class.
Since C doesn't have "class methods" or "private variables", I think you're
probably in the wrong newsgroup - try comp.lang.c++.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.


Even the C++ gurus are unlikely to be able to debug code you don't show
them.

--
Chris "electric hedgehog" Dollin
Nov 14 '05 #2

P: n/a
jeko <a.*********@fastwebnet.it> wrote:
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.


Sorry, but it looks as if you picked the wrong newsgroup. You're here
in comg.lang.c and not comp.lang.c++ - and C doesn't have classes,
methods or private variables. But when you post there you probably
post a bit more of real code. From what you write nobody will be
able to tell you what's exactly going wrong and you might get one
of the standard-joke-answers like that the problem is on line 42...
So show at least how the class looks like, how you define the
instance of the class you're using and what you do in your com-
putations. Best would be a small, working program that exhibits the
problem (as an additional benefit one often finds the error when
one tries to cobble together such an example program).

Regards, Jens
--
\ Jens Thoms Toerring ___ Je***********@physik.fu-berlin.de
\__________________________ http://www.toerring.de
Nov 14 '05 #3

P: n/a
jeko ha scritto:
Hi,
I'm using a class method which read and write on private variable of own
class.
During the first alghoritm cycle, method read and write correclty on
num_elts variable, but during the second cycle as soon as method wants
read (or write) the variable program is aborted and return "segmentation
fault". Why? num_elts is a long variable.

thanks

Andrea


Sorry, this is wrong newsgroup:)
Nov 14 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.