Click here to Skip to main content
15,899,474 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Function to get the local system Administrator Name Pin
enhzflep16-Oct-08 18:58
enhzflep16-Oct-08 18:58 
QuestionHow can I remove an item in Combo box's list box ? Pin
SherTeks16-Oct-08 18:18
SherTeks16-Oct-08 18:18 
AnswerRe: How can I remove an item in Combo box's list box ? Pin
AlexAbramov16-Oct-08 19:59
AlexAbramov16-Oct-08 19:59 
QuestionI need help figuring this out please Pin
LilKoopa16-Oct-08 18:05
LilKoopa16-Oct-08 18:05 
AnswerRe: I need help figuring this out please Pin
User 21559716-Oct-08 18:36
User 21559716-Oct-08 18:36 
GeneralRe: I need help figuring this out please Pin
LilKoopa17-Oct-08 7:51
LilKoopa17-Oct-08 7:51 
AnswerRe: I need help figuring this out please Pin
David Crow17-Oct-08 8:52
David Crow17-Oct-08 8:52 
QuestionInterface Design Question Pin
mombawomba16-Oct-08 16:08
mombawomba16-Oct-08 16:08 
I'm doing a project where I've got 4 classes for a database. I've got CRecordSet derived classes for each of the tables I'm interacting with.

Here's an example of two of the tables:

/**
 * Part Structure.  Holds the information associated with
 * a part in the database's part table (for single part).
 */
struct part
{
    long priKey;
    string partDescription;
};
typedef CArray<part, part> MyPartArray;


class CPartsTable : public CRecordSet
{
    // MFC Junk here

    BOOL AddNew(part& p); // Adds a new part to the table
    BOOL Edit(part p);    // Edits an existing part
    BOOL Delete(part p);  // Removes a part from the table
    BOOL GetList(MyPartArray& list);  // Returns a list of part structs
}

/**
 * Board structure.  Holds the information associated with
 * a single board.
 */
struct board
{
    long priKey;
    long serialNumber;
    long mfgId;
};
typedef CArray<board, board> MyBoardArray;


class CBoardTable : public CRecordSet
{
    // MFC Junk here

    BOOL AddNew(board& p);
    BOOL Edit(board p);
    BOOL Delete(board p);
    BOOL GetList(MyBoardArray& list);
};


I was thinking that it would make my life much easier if I could wrap them in a common interface like so:

class ICommonTable
{
    virtual BOOL AddNew()=0;
    virtual BOOL Edit()=0;
    virtual BOOL Delete()=0;
    virtual BOOL GetList()=0;
};


My question at this point is: how do I handle the parameters to the functions when using the interface?

The only thing I could think to do was to create a parameter base class for the part and board to derive from then use the parameter base class for the ICommonTable parameters:

class ICommonParam {}
typedef CArray <ICommonParam*, ICommonParam*> MyCommonArray;

class ICommonTable
{
    virtual BOOL AddNew(ICommonParam* pItem)=0;
    virtual BOOL Edit(ICommonParam* pItem)=0;
    virtual BOOL Delete(ICommonParam* pItem)=0;
    virtual BOOL GetList(MyCommonArray& list)=0;
};


My problem is that it seems to make the code more complicated.

Is this strategy a good idea? Should I even try to create a common interface?

If anyone has suggestions I'll gladly take them.
AnswerRe: Interface Design Question Pin
Graham Shanks16-Oct-08 23:43
Graham Shanks16-Oct-08 23:43 
QuestionNew to MFC Pin
BobInNJ16-Oct-08 14:51
BobInNJ16-Oct-08 14:51 
AnswerRe: New to MFC Pin
mombawomba16-Oct-08 16:22
mombawomba16-Oct-08 16:22 
QuestionAssignment Code Pin
dtaylor0116-Oct-08 12:53
dtaylor0116-Oct-08 12:53 
AnswerRe: Assignment Code Pin
BobInNJ16-Oct-08 13:40
BobInNJ16-Oct-08 13:40 
GeneralRe: Assignment Code Pin
dtaylor0116-Oct-08 14:21
dtaylor0116-Oct-08 14:21 
GeneralRe: Assignment Code Pin
BobInNJ16-Oct-08 14:29
BobInNJ16-Oct-08 14:29 
GeneralRe: Assignment Code Pin
dtaylor0116-Oct-08 14:36
dtaylor0116-Oct-08 14:36 
GeneralRe: Assignment Code Pin
BobInNJ16-Oct-08 14:40
BobInNJ16-Oct-08 14:40 
GeneralRe: Assignment Code [modified] Pin
dtaylor0116-Oct-08 14:46
dtaylor0116-Oct-08 14:46 
GeneralRe: Assignment Code Pin
BobInNJ16-Oct-08 14:57
BobInNJ16-Oct-08 14:57 
GeneralRe: Assignment Code Pin
dtaylor0116-Oct-08 15:05
dtaylor0116-Oct-08 15:05 
QuestionRegEnumValue() returns garbage value for DWORD and BINARY Datatype! Pin
Supriya Tonape16-Oct-08 11:38
Supriya Tonape16-Oct-08 11:38 
AnswerRe: RegEnumValue() returns garbage value for DWORD and BINARY Datatype! Pin
CPallini16-Oct-08 12:07
mveCPallini16-Oct-08 12:07 
GeneralRe: RegEnumValue() returns garbage value for DWORD and BINARY Datatype! Pin
Supriya Tonape17-Oct-08 10:18
Supriya Tonape17-Oct-08 10:18 
GeneralRe: RegEnumValue() returns garbage value for DWORD and BINARY Datatype! Pin
CPallini17-Oct-08 10:51
mveCPallini17-Oct-08 10:51 
GeneralRe: RegEnumValue() returns garbage value for DWORD and BINARY Datatype! Pin
Supriya Tonape18-Oct-08 23:21
Supriya Tonape18-Oct-08 23:21 

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.