Click here to Skip to main content
15,916,835 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Faster than memcpy()... Pin
BobInNJ20-Nov-08 12:51
BobInNJ20-Nov-08 12:51 
GeneralRe: Faster than memcpy()... Pin
PJ Arends20-Nov-08 14:41
professionalPJ Arends20-Nov-08 14:41 
GeneralRe: Faster than memcpy()... Pin
Randor 20-Nov-08 22:30
professional Randor 20-Nov-08 22:30 
GeneralRe: Faster than memcpy()... Pin
BobInNJ21-Nov-08 6:06
BobInNJ21-Nov-08 6:06 
GeneralRe: Faster than memcpy()... Pin
Randor 21-Nov-08 6:21
professional Randor 21-Nov-08 6:21 
AnswerRe: Faster than memcpy()... Pin
cmk20-Nov-08 16:51
cmk20-Nov-08 16:51 
QuestionA Question about Constructors Pin
BobInNJ20-Nov-08 8:17
BobInNJ20-Nov-08 8:17 
AnswerRe: A Question about Constructors Pin
led mike20-Nov-08 8:55
led mike20-Nov-08 8:55 
AnswerRe: A Question about Constructors Pin
Venkata Rama Subbarao20-Nov-08 9:08
Venkata Rama Subbarao20-Nov-08 9:08 
QuestionNeed Help in Read a file at compilation time to initialize variable Pin
scamguru20-Nov-08 7:16
scamguru20-Nov-08 7:16 
AnswerRe: Need Help in Read a file at compilation time to initialize variable Pin
Code-o-mat20-Nov-08 7:28
Code-o-mat20-Nov-08 7:28 
GeneralRe: Need Help in Read a file at compilation time to initialize variable Pin
scamguru20-Nov-08 7:30
scamguru20-Nov-08 7:30 
GeneralRe: Need Help in Read a file at compilation time to initialize variable Pin
toxcct20-Nov-08 7:38
toxcct20-Nov-08 7:38 
QuestionDefinitive Direct3D example Pin
Jim Crafton20-Nov-08 7:09
Jim Crafton20-Nov-08 7:09 
AnswerRe: Definitive Direct3D example Pin
Code-o-mat20-Nov-08 7:19
Code-o-mat20-Nov-08 7:19 
GeneralRe: Definitive Direct3D example Pin
Jim Crafton20-Nov-08 7:29
Jim Crafton20-Nov-08 7:29 
GeneralRe: Definitive Direct3D example Pin
Code-o-mat20-Nov-08 7:58
Code-o-mat20-Nov-08 7:58 
GeneralRe: Definitive Direct3D example Pin
cmk20-Nov-08 12:39
cmk20-Nov-08 12:39 
QuestionProbem with Directory Settings - Read Only Pin
Larry Mills Sr20-Nov-08 6:47
Larry Mills Sr20-Nov-08 6:47 
AnswerRe: Probem with Directory Settings - Read Only Pin
Venkata Rama Subbarao20-Nov-08 9:18
Venkata Rama Subbarao20-Nov-08 9:18 
QuestionC++ destructor problem Pin
Fred Andres20-Nov-08 4:44
Fred Andres20-Nov-08 4:44 
I have created the following class:

class variable {
public:
// The core data for a variable is an array of values
// Variable 0 will always be the error variable and
// variable 1 will always be the dependent variable.
string name;
bool isStochastic;
bool isDependent;
bool used;
bool isSeasDummy;
bool isKeeper;
double firstValue;
date firstDate;
double *values;
date *dates;
int time0;
int numTimes;
int fillRule;
bool hasLowerBound;
double lowerBound;
bool hasUpperBound;
double upperBound;
bool hasLeads;
int leads;
int lags;
bool keepAtStart;
variable() {
numTimes = -1;
used = false;
isStochastic = true;
isKeeper = false;
hasLeads = true;
};
// This constructor sets up a variable dynamically
// allocating the value and date arrays.
variable(int inTimes) {
values = new double [inTimes + 20];
dates = new date [inTimes + 20];
numTimes = inTimes;
isSeasDummy = false;
used = false;
isStochastic = true;
isKeeper = false;
keepAtStart = false;
hasLowerBound = false;
lowerBound = smallNumber;
hasUpperBound = false;
upperBound = bigNumber;
leads = 0;
lags = 0;
isDependent = false;
};
void insert(int inTime0, date inDate) {
for (time0 = numTimes; time0 > inTime0; time0--) {
values[time0] = values[time0 - 1];
dates[time0] = dates[time0 - 1];
};
dates[inTime0] = inDate;
if (fillRule == 0) {
values[time0] = 0;
};
if (fillRule == 1) {
values[time0] = values[time0 - 1];
};
if (fillRule == 2) {
values[time0] = values[time0 + 1];
};
if (fillRule == 3) {
values[time0] = (values[time0 - 1] + values[time0 + 1])/2;
};
if (fillRule == 4) {
if (values[time0 + 1] > values[time0 - 1]) {
values[time0] = values[time0 + 1];
}
else {
values[time0] = values[time0 - 1];
};
};
if (fillRule == 5) {
if (values[time0 + 1] > values[time0 - 1]) {
values[time0] = values[time0 - 1];
}
else {
values[time0] = values[time0 + 1];
};
};
numTimes++;
};
~variable() {
delete [] values;
delete [] dates;
cout << "got into variable destructor" << '\n';
};
};

Then I use the following code to create an array of variables:

variable *vars;
vars = new variable [numVars + maxInterventions + 1];
for (var0 = 0; var0 < numVars + maxInterventions + 1; var0++) {
vars[var0] = variable(completeTimes);
vars[var0].numTimes = numTimes;
};

Before I added the destructor, this code worked fine. However, now when the vars[var0] = variable(completeTimes);
statement is executed, it calls the destructor and destroys my array. Is there a way I can inhibit the use of the destructor? Or is there a way I can use the second constructor at the same time that I allocate the array?
AnswerRe: C++ destructor problem Pin
Cedric Moonen20-Nov-08 4:57
Cedric Moonen20-Nov-08 4:57 
GeneralRe: C++ destructor problem Pin
Fred Andres20-Nov-08 5:07
Fred Andres20-Nov-08 5:07 
QuestionRe: C++ destructor problem Pin
David Crow20-Nov-08 5:05
David Crow20-Nov-08 5:05 
AnswerRe: C++ destructor problem Pin
Fred Andres20-Nov-08 5:09
Fred Andres20-Nov-08 5:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.