Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*Peop le;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
what could be the problem??
many thanks. 6 2934 ha*********@gma il.com wrote:
Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*Peop le;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
what could be the problem??
Almost anything. Please post the code that causes the problem,
preferably a whole program.
Debugging C++ isn't easy, if it was possible to fix a bug from a one
line description and an error message, then C++ programmers would get
paid a whole lot less.
Only the code will do, post it.
john
On Jul 24, 11:07 pm, John Harrison <john_androni.. .@hotmail.com>
wrote:
hadad.ya...@gma il.com wrote:
Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*Peop le;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
what could be the problem??
Almost anything. Please post the code that causes the problem,
preferably a whole program.
Debugging C++ isn't easy, if it was possible to fix a bug from a one
line description and an error message, then C++ programmers would get
paid a whole lot less.
Only the code will do, post it.
john
Here is the problematic function:
void Elections::read _votes()
{
// handeling the first ballot
Ballot * oneballot;
oneballot = read_and_normal ize_inputballot ();
if (oneballot!=NUL L)
{
ballots.push_ba ck(oneballot);
}
//handeling the rest of the ballots
string command;
while (cin>>command)
{
if (command=="Inpu tBallot")
{
oneballot = read_and_normal ize_inputballot ();
if (oneballot!=NUL L)
{
ballots.push_ba ck(oneballot); - crash here!!!!!,
ballots is not null neither.
}
}
else
{
return ;
}
}
}
On Jul 25, 9:21 am, "hadad.ya...@gm ail.com" <hadad.ya...@gm ail.com>
wrote:
On Jul 24, 11:07 pm, John Harrison <john_androni.. .@hotmail.com>
wrote:
[Incomplete code snipped]
There's not enough code here to diagnose the problem.
The best thing to do is to pare the code down to a minimum single
*compilable* body that illustrates the problem, with an int main() and
all, and post that. This has two advantages:
1. People can copy-and-paste your code direcly and compile it
themselves;
2. In paring the code down, you will very likely see the problem
yourself.
HTH.
On Wed, 25 Jul 2007 08:21:41 +0000, ha*********@gma il.com wrote:
On Jul 24, 11:07 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
>hadad.ya...@gm ail.com wrote:
Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*Peop le;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
what could be the problem??
Almost anything. Please post the code that causes the problem, preferably a whole program.
Debugging C++ isn't easy, if it was possible to fix a bug from a one line description and an error message, then C++ programmers would get paid a whole lot less.
Only the code will do, post it.
john
Here is the problematic function:
void Elections::read _votes()
{
// handeling the first ballot
Ballot * oneballot;
How is 'Ballot' defined?
oneballot = read_and_normal ize_inputballot (); if (oneballot!=NUL L)
What does 'read_and_norma lize_inputballo t()' do?
{
ballots.push_ba ck(oneballot);
How is 'ballots' defined?
}
//handeling the rest of the ballots
string command;
while (cin>>command)
{
if (command=="Inpu tBallot")
{
oneballot = read_and_normal ize_inputballot (); if
(oneballot!=NUL L)
{
ballots.push_ba ck(oneballot); - crash here!!!!!,
ballots is not null neither.
}
}
else
{
return ;
}
}
}
*Please* try and post an *entire, compilable* program that demonstrates
your problem (see the FAQ): http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
My suspicion would be that the problem is being caused by a bug in some
code that you haven't posted, but who knows?
--
Lionel B
Lionel B wrote:
On Wed, 25 Jul 2007 08:21:41 +0000, ha*********@gma il.com wrote:
>On Jul 24, 11:07 pm, John Harrison <john_androni.. .@hotmail.comwr ote:
>>hadad.ya...@g mail.com wrote: Hello, i am new to c++, i hav a vector of typed object: vector<Man*P eople; When i do a second pushback, even for the same object the program crash say: "An Access Violation (Segmentation fault) raised in your program" what could be the problem?? Almost anything. Please post the code that causes the problem, preferably a whole program.
Debugging C++ isn't easy, if it was possible to fix a bug from a one line description and an error message, then C++ programmers would get paid a whole lot less.
Only the code will do, post it.
john
Here is the problematic function:
void Elections::read _votes() { // handeling the first ballot Ballot * oneballot;
How is 'Ballot' defined?
> oneballot = read_and_normal ize_inputballot (); if (oneballot!=NUL L)
What does 'read_and_norma lize_inputballo t()' do?
--snip--
My quess is that read_and_normal ize_inputballot () returns address of
local (stack) variable. Or it uses dynamic memory in which case the
allocation size was too small.
Or something else is corrupting heap.
Those are the usual beginner mistakes.
ismo
<ha*********@gm ail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Jul 24, 11:07 pm, John Harrison <john_androni.. .@hotmail.com>
wrote:
>hadad.ya...@gm ail.com wrote:
Hello,
i am new to c++,
i hav a vector of typed object:
vector<Man*Peop le;
When i do a second pushback, even for the same object the program
crash say:
"An Access Violation (Segmentation fault) raised in your program"
what could be the problem??
Almost anything. Please post the code that causes the problem, preferably a whole program.
Debugging C++ isn't easy, if it was possible to fix a bug from a one line description and an error message, then C++ programmers would get paid a whole lot less.
Only the code will do, post it.
john
Here is the problematic function:
void Elections::read _votes()
{
// handeling the first ballot
Ballot * oneballot;
oneballot = read_and_normal ize_inputballot ();
if (oneballot!=NUL L)
{
ballots.push_ba ck(oneballot);
}
//handeling the rest of the ballots
string command;
while (cin>>command)
{
if (command=="Inpu tBallot")
{
oneballot = read_and_normal ize_inputballot ();
if (oneballot!=NUL L)
{
ballots.push_ba ck(oneballot); - crash here!!!!!,
ballots is not null neither.
}
}
else
{
return ;
}
}
}
This code, in and of itself, should not produce a problem, so it must be
somewhere we can't see. Such as in read_and_normal ize_inputballot ();
Please post complete compilable code that reproduces the problem. In this
case include read_and_normal ize_inputballot ();, definition of ballots, and a
main that executes and causes the error.
I suspect that just by you doing this you'll find the problem. Or when you
do this, you'll find it's no longer crashing, and find the error is
elsewhere.
Access violations gernally mean that the computer is trying to read memory
it doesn't "own", that something is pointing to somewhere it shouldn't. A
lot of things can cause this, not only a pointer just pointing to somewhere
it shouldn't, but heap/stack corruption, array overflows, etc... Usually
reducing the code to the smallest code that reproduces the problem shows the
error, as when you take something thought to be unrelated out it suddently
starts to work. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael Olea |
last post by:
Here is a design problem I ran into this am - and I have cleaned the
bathroom,
scrubbed toilet sink and tub, windexed all glass, mopped the floor, and
vacuumed the house - no dice, the problem is still there. Maybe y'all have
some ideas?
Background
==========
The basic idea behind templates, of course, is that much code is independent
|
by: CES |
last post by:
All,
Could someone please look at this and tell me what's wrong... the function works properly in FireFox but in IE onmouseover it replaces the innerHTML. So the original html:
at info@test.com Thank you for your consideration.
becomes
at mailto:info@test.com:?SUBJECT=Request for additional information - Package id : /*JS var*/ Thank you for your consideration.
|
by: Mark Dicken |
last post by:
Hi All,
I am trying to Pass A Collection To A FUNCTION ??? (Access 2000)
I have a Class called BO (for Business Objects)
Within BO I have a Function called ShowCollection
Public Sub showcollection(colCollection As Collection)
MsgBox "colCollection(2)=" & colCollection(2)
|
by: E. Robert Tisdale |
last post by:
Is a function an object?
|
by: Luke |
last post by:
Hi
I have the following code which is an ASP questionnaire using an Access
database. (I am using access as I have no choice!). Basically there is an
html form which submits the form to the page below and the code below
submits the data to the DB and redirects the user.
The code works locally on http://localhost or http://127.0.0.1 but when I
upload it to a site (I have tried a few and they all error) it says "An
error occurred on the...
| |
by: ss |
last post by:
i read a few posts about global function access. well i am not
interested in global functions. rather, i am seeking for a way to may
my call in ASPX pages but not the code behind.
for example: in a datagrid bind() in ASPX:
<%# container.dataitem("date") %>
i'd like to call
<%# specialFormat( container.dataitem("date") ) %>
I noticed that format from VB is available here.
|
by: Yanping Zhang |
last post by:
Hi All,
I need to use this C routine in python and there is a void pointer parameter in it:
(this routine was written by someone else):
myfunc(int a, (void *)userdata, bool b)
I saw someone in his C++ wrapper used this routine in this way:
myfunc(a, (void *)0x5a5a5a5a, b)
|
by: embarkr |
last post by:
I am getting the error:
"Violation of PRIMARY KEY constraint 'PK_tblCustomsTariffTreeMap'. Cannot insert duplicate key in object 'dbo.tblCustomsTariffCodeTreeMap'."
However, the record I am inserting does not represent a duplicate on the primary key.
To ensure this I ran the following and still got the error:
update tblCustomsTariffCodeTreeMap
set TariffCodeID = (SELECT max(tariffcodeid)+1 from tblCustomsTariffCodeTreeMap)
where...
|
by: dolphin |
last post by:
Hello everyone! Can a static member function access non-static member?
I think it is illegal.Is it right?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |