Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to Insert Data In Excel Pin
David Crow10-Jul-09 3:04
David Crow10-Jul-09 3:04 
GeneralRe: How to Insert Data In Excel Pin
Anubhava Dimri10-Jul-09 18:16
Anubhava Dimri10-Jul-09 18:16 
QuestionWindows Workflow Foundation Pin
RS.Ratheesh7-Jul-09 2:41
RS.Ratheesh7-Jul-09 2:41 
AnswerRe: Windows Workflow Foundation Pin
Kevin McFarlane7-Jul-09 6:10
Kevin McFarlane7-Jul-09 6:10 
GeneralRe: Windows Workflow Foundation Pin
RS.Ratheesh7-Jul-09 20:19
RS.Ratheesh7-Jul-09 20:19 
QuestionHow to get international date format in lotus notes Pin
kirankatta7-Jul-09 2:37
kirankatta7-Jul-09 2:37 
QuestionRe: How to get international date format in lotus notes Pin
David Crow7-Jul-09 3:07
David Crow7-Jul-09 3:07 
QuestionIs it better to use a class or struct in this case? Pin
Mike the Red7-Jul-09 1:57
Mike the Red7-Jul-09 1:57 
I'm implementing a class to manage an array of objects created on the heap.. Something like:
class Manager {
public:
     Manager(void);
     ~Manager(void);
     Populate(LPVOID data);
     Retreive(int index);
private:
     myObject * objects;
     int count;
}
myObject needs to contain a char array and a BYTE array, both also on the heap. My first inclination was to use a STRUCT:
struct myObject {
     char * szName;
     byte * lpbData;
};
As I thought about it, though, it seemed memory clean-up would be easier if I made myObject a class with public members, initialize the values with a constructor, and let the destructor handle memory clean-up:
class myObject {
public:
myObject(char * name, BYTE * data, DWORD size) { 
     this->szName = new char[strlen(name)+1]; strcpy(this->szName, name, strlen(name);
     this->lpbData = new BYTE[size]; memcpy(this->lpbData, data, size);
     this->dwSize = size;
}
~myObject(void) { delete this->szName; delete this->lpbData; }
public:
     char * szName;
     BYTE * lpbData;
     DWORD dwSize;
};
Performance is critical in this particular application, and I'm thinking there's probably more to consider in the class vs. struct than just what makes memory cleanup easiest for me in the other classes.

Can anybody offer some help, here, or point me in the direction of a reference that might help?

Thanks,
MZR
AnswerRe: Is it better to use a class or struct in this case? Pin
CPallini7-Jul-09 2:04
mveCPallini7-Jul-09 2:04 
GeneralRe: Is it better to use a class or struct in this case? Pin
«_Superman_»7-Jul-09 2:09
professional«_Superman_»7-Jul-09 2:09 
GeneralRe: Is it better to use a class or struct in this case? Pin
CPallini7-Jul-09 2:31
mveCPallini7-Jul-09 2:31 
GeneralEverytime I think I'm starting to get the basics down... I ask a stupid question.. Thanks, guys! Pin
Mike the Red7-Jul-09 2:37
Mike the Red7-Jul-09 2:37 
GeneralRe: Is it better to use a class or struct in this case? Pin
Maximilien7-Jul-09 3:27
Maximilien7-Jul-09 3:27 
GeneralRe: Is it better to use a class or struct in this case? Pin
CPallini7-Jul-09 5:40
mveCPallini7-Jul-09 5:40 
GeneralRe: Is it better to use a class or struct in this case? Pin
Rajesh R Subramanian7-Jul-09 7:26
professionalRajesh R Subramanian7-Jul-09 7:26 
GeneralRe: Is it better to use a class or struct in this case? Pin
CPallini7-Jul-09 10:34
mveCPallini7-Jul-09 10:34 
GeneralRe: Is it better to use a class or struct in this case? Pin
Rajesh R Subramanian7-Jul-09 18:03
professionalRajesh R Subramanian7-Jul-09 18:03 
GeneralRe: Is it better to use a class or struct in this case? Pin
CPallini7-Jul-09 20:50
mveCPallini7-Jul-09 20:50 
GeneralRe: Is it better to use a class or struct in this case? Pin
Rajesh R Subramanian7-Jul-09 22:14
professionalRajesh R Subramanian7-Jul-09 22:14 
QuestionVC++ win32 projects Pin
Satish Pai7-Jul-09 1:17
Satish Pai7-Jul-09 1:17 
AnswerRe: VC++ win32 projects Pin
«_Superman_»7-Jul-09 1:24
professional«_Superman_»7-Jul-09 1:24 
GeneralRe: VC++ win32 projects Pin
Satish Pai7-Jul-09 2:15
Satish Pai7-Jul-09 2:15 
GeneralRe: VC++ win32 projects Pin
«_Superman_»7-Jul-09 2:21
professional«_Superman_»7-Jul-09 2:21 
GeneralRe: VC++ win32 projects Pin
Satish Pai7-Jul-09 2:24
Satish Pai7-Jul-09 2:24 
Questionwhen to use switch-case and when to use if-else Pin
pandit847-Jul-09 0:10
pandit847-Jul-09 0:10 

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.