heap and co.

M

Michael Sgier

Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?

record = new DataRecord[nRecords];

and how could i declare that? Propositions?
shouldn't record be like: record * ? but what type is record and DataRecord?
Thanks
Michael
 
B

BigBrian

Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?

record = new DataRecord[nRecords];

and how could i declare that?
Thanks
Michael

One way would be...

DataRecord * record = new DataRecord[nRecords];

or...

std::auto_ptr said:
but what type is record and DataRecord?

How are we supposed to know? Do a grep on your code and find out where
it's defined.


-Brian
 
H

Howard

"heap and co."? What's that subject supposed to mean? (Meaningful subjects
help people decide if they think they can help.)
Hi
i get error: 'record' was not declared in this scope
so i look in the header...nothing also nothing like DataRecord
but: unsigned long nRecords;
So what could that be?

That you haven't declared record anywhere, perhaps?
record = new DataRecord[nRecords];

and how could i declare that?

How can you declare record? From the line of code above, you probably want
a pointer to a DataRecord. That would be DataRecord*. (If you don't know
that, you _really_ need to open your books and read some more.)
Propositions?
What?

shouldn't record be like: record * ?

That would define record as a pointer to a type called record.
but what type is record and DataRecord?

We have no way of knowing anything about the type DataRecord. You haven't
told us!

You probably just need "DataRecord* record;" somehwere. But since we can't
see your code, I have no idea where. Either as a member variable, a global
variable, or a local variable (somewhere in the function, before you use
it).

Howard
 
J

Jerry Coffin

[ ... ]
std::auto_ptr<DataRecord> record( new DataRecord[nRecords] );

This gives undefined behavior (auto_ptr doesn't use the array form of
delete).
 
M

Michael Sgier

it get error: `DataRecord' is not a type

declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this
CDatabaseRecord* record = new DataRecord[nRecords];
how should the line above look like?

actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record? how?
what about DataRecord? thats an array? how do i declare it?`
 
M

Michael Sgier

originally only that code was in the project i try to compile:
record = new DataRecord[nRecords];

no declaration or record nor DatRecord...maybe explicitely to block out
stupid,lazy people like me ;-)
only this declaration:
unsigned long nRecords;
Thanks michael
 
R

Rolf Magnus

Michael said:
it get error: `DataRecord' is not a type

Then that's probably true.
declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this

Doesn't make sense. An array must have a size.
CDatabaseRecord* record = new DataRecord[nRecords];

This can't be written directly in a class definition.
how should the line above look like?

How would we know?
actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record?

Depends. Is it supposed to be a member of that class?
how?
what about DataRecord? thats an array? how do i declare it?`

Again, how would we know? Declare it as whatever you need it to be.
 
J

Jim Langston

Michael Sgier said:
it get error: `DataRecord' is not a type

declared so in class CDatabase {
unsigned long nRecords;
int DataRecord[]; //i simply guessed this
CDatabaseRecord* record = new DataRecord[nRecords];
how should the line above look like?

actually i havent declred record anywhere. do i need in class
CDatabaseRecord to declare record? how?
what about DataRecord? thats an array? how do i declare it?`

You have CDatabaseRecord, so it looks like your class for records is
CDatabaseRecord. So if you want an array of these, it would be:

CDatabaseRecord* records = new CDatabaseRecord[nRecords];
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top