RunTime error
Sep 28, 2009 at 8:22pm UTC
I'm baffled. I know where the problem line is. I just don't understand the problem except to add that it likely relates to either pointer or reference or both. Hopefully, all code needed is included. Thanks in advance.
Unhandled exception at 0x5dd97b3f (msvcp90d.dll) in Parser6.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd.
FROM OUTPUT...
First-chance exception at 0x5dd97b3f (msvcp90d.dll) in Parser6.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd.
Unhandled exception at 0x5dd97b3f (msvcp90d.dll) in Parser6.exe: 0xC0000005: Access violation writing location 0xcdcdcdcd.
Here is the line from some internal file that is getting pointed at by the compiler. FileName = xutility. Bad line is labeled.
inline void __CLR_OR_THIS_CALL _Container_base_secure::_Orphan_all() const
{ // orphan all iterators
_Lockit _Lock(_LOCK_DEBUG);
if (_Myfirstiter != _IGNORE_MYITERLIST)
{
for (_Iterator_base **_Pnext = (_Iterator_base **)&_Myfirstiter;
*_Pnext != 0; *_Pnext = (*_Pnext)->_Mynextiter)
BAD LINE HERE --> (*_Pnext)->_Mycont = 0;
*(_Iterator_base **)&_Myfirstiter = 0;
}
}
Here is the Collector constructor with the problem code labeled near the end.
Note that the constructor is taking in a reference. This may be related to error.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#include "Collector.h"
#include "Token_stream.h"
#include "Multiplier.h"
#include <vector>
#include <iostream>
using namespace std;
Collector::Collector(Multiplier& myMultiBox, int MaxSNM): myMultiplier(myMultiBox)
{
cin.clear();
cin.ignore(1000, '\n' );
BaseIP = GetOctets2( MaxSNM);
NetworkBits = ConvertToNetworkBits( BaseIP);
vector<SimpleBox*> Boxes;
vector<int > test(31,9);
for (int i = 0; i < (myMultiplier.GetTheBoxSet()).size(); i++)
{
Boxes = (myMultiplier.GetABoxMaker(i))->GetMyBoxes();
for (int z = 0; z < Boxes.size(); z++)
{
THIS DOESN'T WORK-> Boxes[z]->SetMyNetworkBits(test);
THIS DOESN' T WORK-> Boxes[z]->SetMyBaseIP(BaseIP);
THIS WILL RUN ALONE-> Boxes[z]->PRINT_NETWORK();
}
}
}
Here is main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#include "AllHeaders.h"
using namespace std;
int main()
try {
StartMeUp KickStart;
Multiplier MultiBox(KickStart.GetMyHosts());
BoxMaker* temp = MultiBox.GetABoxMaker(0);
BoxMaker* temp1 = MultiBox.GetABoxMaker(1);
BoxMaker* temp2 = MultiBox.GetABoxMaker(2);
BoxMaker* temp3 = MultiBox.GetABoxMaker(3);
PureStack FirstT(temp );
StackSmallHigh SecondT(temp1);
PureReserve ThirdT(temp2);
ReserveSmall FourthT(temp3);
cout << endl;
int MaxSNM = temp->GetMyVLSM();
Collector TheCollector(MultiBox, MaxSNM);
system("PAUSE" );
return 0;
}
catch (exception& e)
{
cerr << e.what() << endl;
keep_window_open ("~1" );
return 1;
}
catch (...)
{
cerr << "exception \n" ;
keep_window_open ("~2" );
return 2;
}
all headers:
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
#include <vector>
#include "StartMeUp.h"
#include "Multiplier.h"
#include "Stroustrup.h"
#include "MakeSmall.h"
#include "BoxMaker.h"
#include "PureStack.h"
#include "StackSmallHigh.h"
#include "PureReserve.h"
#include "ReserveSmall.h"
#include "Collector.h"
Here are the .h files
Collector
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
#ifndef Collector_h
#define Collector_h
#include "Multiplier.h"
#include "Token_stream.h"
#include <vector>
using std::vector;
class Collector
{
public :
Collector(Multiplier&, int );//int is the MaxSubnet for pure stack passed in from main
int GetMyBaseIP();
vector<int > GetMyNetworkBits() ;
private :
//Members
int MaximumMask;
vector<Token> BaseIP;
vector<int > NetworkBits;
//functions
vector<Token> GetNumber(bool , vector<Token>, int , char SNM = '*' , int MaxSNM = 30);
vector<Token> GetNumberAndDot(bool broken, vector<Token> Octets, int limit);
vector<Token> GetOctets2(/*vector<Token>,*/ int );
vector<int > ConvertToNetworkBits(vector<Token>);
Multiplier myMultiplier;
};
#endif
[\code]
[code]
Multiplier
#ifndef Multiplier_h
#define Multiplier_h
#include "Token_stream.h"
#include "BoxMaker.h"
#include <vector>
using std::vector;
class Multiplier
{
public :
Multiplier(vector<Token> hosts_in);
vector<BoxMaker*> GetTheBoxSet();
BoxMaker* GetABoxMaker(int i);
int GetMyVLSM( int BM);
private :
vector<Token> hosts;
vector<BoxMaker*> BoxSet;
};
#endif
SimpleBox
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
#ifndef SimpleBox_h
#define SimpleBox_h
#include "Token_stream.h"
#include <vector>
using std::vector;
class SimpleBox
{
public :
SimpleBox (vector<Token> hosts);
void ResetStatics();
void SetMyNetworkBits(vector<int >);
void SetMyBaseIP(vector<Token> );
void SetNetwork(int network );
void SetVLSM(int SNM);
void PrintBoxValue();
void SetMyHostsTest();
int GetMyBlockSize();
int GetMyNetwork();
int GetMyVLSM();
void PRINT_NETWORK();
private :
vector<Token> myHostsVector; //passed in
vector<int > myHostBits;
int myBlockSize;
int myHosts;
int myNetwork;
int myHostElement;
int myVLSM;
void FigureBlockSize();
int myBroadCast;
vector<int > myNetworkBits;
vector<Token> BaseIP;
int MaxSNM;
static int s_network;
static int s_globalcounter;
};
#endif
BoxMaker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#ifndef BoxMaker_h
#define BoxMaker_h
#include "SimpleBox.h"
#include "Token_stream.h"
#include <vector>
class BoxMaker
{
public :
BoxMaker (vector<Token> Hosts_in, int i);
void PRINT_TEST();
vector<SimpleBox*> GetMyBoxes();
void SetMyNetwork(int network, int number );
void SetMyVLSM(int network, int VLSM);
int GetMyVLSM();
private :
vector<Token> theHosts;
vector<SimpleBox*> myBoxes;
};
#endif
SetmyNetworkBits
1 2 3 4 5 6 7
#include "SimpleBox.h"
#include <vector>
void SimpleBox::SetMyNetworkBits (vector<int > theNetworkBits)
{
myNetworkBits = theNetworkBits;
}
SetmyBaseIP
1 2 3 4 5 6 7 8 9
#include "SimpleBox.h"
#include <vector>
void SimpleBox::SetMyBaseIP (vector<Token> theBaseIP)
{
BaseIP = theBaseIP;
}
Last edited on Sep 28, 2009 at 8:23pm UTC
Topic archived. No new replies allowed.