469,950 Members | 2,304 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

segmentation fault on private variable

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
3 1880
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
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
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.

Similar topics

1 post views Thread by Justin Tang | last post: by
2 posts views Thread by jeko | last post: by
3 posts views Thread by Amar Prakash Tripaithi | last post: by
1 post views Thread by Amar Prakash Tripaithi | last post: by
3 posts views Thread by madunix | last post: by
3 posts views Thread by jr.freester | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.