Click here to Skip to main content
16,014,392 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Basic OOP Question Pin
Joaquín M López Muñoz7-Feb-02 2:13
Joaquín M López Muñoz7-Feb-02 2:13 
GeneralAvailable Comm Ports Pin
Steve Thresher4-Feb-02 6:12
Steve Thresher4-Feb-02 6:12 
GeneralRe: Available Comm Ports Pin
Rick York4-Feb-02 6:44
mveRick York4-Feb-02 6:44 
GeneralRe: Available Comm Ports Pin
Steve Thresher5-Feb-02 2:10
Steve Thresher5-Feb-02 2:10 
QuestionRestrictions of TreeControl under XP [or just another XP bug]? Pin
Andreas Saurwein4-Feb-02 5:56
Andreas Saurwein4-Feb-02 5:56 
QuestionWhat does an object REALLY look like? Pin
Jamie Hale4-Feb-02 5:51
Jamie Hale4-Feb-02 5:51 
AnswerRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 6:04
Joaquín M López Muñoz4-Feb-02 6:04 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 6:32
Jamie Hale4-Feb-02 6:32 
I appreciate the correction regarding sizeof() - it means I'm on the right track. I had a look at your allocator, and that's exactly what I'm trying to do, more or less. I think I'd like to try to correct my code before trying your allocator - no offence intended, I like to understand the problem and the solution before I cut and paste. Smile | :)

Having read through your article and your code, I have a feeling my problem is just a casting issue. Here is a small chunk of the code (error checking removed):

class ISlice {
virtual void Something() = 0;
};

class CDataSlice : public ISlice {
...
};

// blocks
std::list<byte *> CDataSliceCache::m_listBlocks;

// free/unused slices
std::list<CDataSlice *> CDataSliceCache::m_listFree;

void CDataSliceCache::AddBlock() {

byte *pBase;
CDataSlice *pSlice;

// allocate and store the block
pBase = new byte[m_nBlockSize * sizeof(CDataSlice)];
m_listBlocks.push_back(pBase);

// add internal pointers to free slice list
for(int i = 0; i < m_nBlockSize; i++) {
pSlice = reinterpret_cast<CDataSlice *>(&pBase[i * sizeof(CDataSlice)]);
m_listFree.push_back(pSlice);
}
}

Does that reinterpret_cast<> look like it will work? If so, maybe my trouble is elsewhere...

Thanks for the input.

J

GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 7:25
Joaquín M López Muñoz4-Feb-02 7:25 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 7:56
Jamie Hale4-Feb-02 7:56 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 8:05
suss4-Feb-02 8:05 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:34
Jamie Hale4-Feb-02 9:34 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 8:20
Joaquín M López Muñoz4-Feb-02 8:20 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:12
Jamie Hale4-Feb-02 9:12 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 9:22
Joaquín M López Muñoz4-Feb-02 9:22 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:32
Jamie Hale4-Feb-02 9:32 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:39
Jamie Hale4-Feb-02 9:39 
GeneralRe: What does an object REALLY look like? Pin
Joaquín M López Muñoz4-Feb-02 11:21
Joaquín M López Muñoz4-Feb-02 11:21 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 18:25
Jamie Hale4-Feb-02 18:25 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 9:48
suss4-Feb-02 9:48 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 9:50
Jamie Hale4-Feb-02 9:50 
GeneralRe: What does an object REALLY look like? Pin
4-Feb-02 11:19
suss4-Feb-02 11:19 
GeneralRe: What does an object REALLY look like? Pin
Jamie Hale4-Feb-02 18:17
Jamie Hale4-Feb-02 18:17 
GeneralRe: What does an object REALLY look like? Pin
5-Feb-02 6:10
suss5-Feb-02 6:10 
Generalremove deleted records Pin
jafrazee4-Feb-02 5:27
jafrazee4-Feb-02 5:27 

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.