Click here to Skip to main content
14,361,624 members

C / C++ / MFC

 
GeneralRe: Popularity Of C among developer Pin
Richard MacCutchan17-Apr-19 4:27
protectorRichard MacCutchan17-Apr-19 4:27 
QuestionRe: Popularity Of C among developer Pin
David Crow17-Apr-19 4:50
memberDavid Crow17-Apr-19 4:50 
AnswerRe: Popularity Of C among developer Pin
Richard MacCutchan17-Apr-19 7:19
protectorRichard MacCutchan17-Apr-19 7:19 
GeneralRe: Popularity Of C among developer Pin
David Crow17-Apr-19 7:27
memberDavid Crow17-Apr-19 7:27 
GeneralRe: Popularity Of C among developer Pin
Richard MacCutchan17-Apr-19 7:35
protectorRichard MacCutchan17-Apr-19 7:35 
QuestionRe: Popularity Of C among developer Pin
David Crow17-Apr-19 8:00
memberDavid Crow17-Apr-19 8:00 
AnswerRe: Popularity Of C among developer Pin
Richard MacCutchan17-Apr-19 22:30
protectorRichard MacCutchan17-Apr-19 22:30 
AnswerRe: Popularity Of C among developer Pin
John R. Shaw19-Apr-19 9:47
memberJohn R. Shaw19-Apr-19 9:47 
Interesting discussion, since i have implemented similar functionality in the passed. The only thing the user had to work with was a handle and predefined functions that take the handle as an argument.
I used this method to create STL type containers. The drawback being there was no type checking, as the data stored was just a block of memory supplied by the user.
I used a similar method when creating my old DOS interface library, it would wire up the function pointers defined in the window structure at run-time. Basically all visual elements were a window; how they were wired-up depended on the function called to create them.

You cannot created protected members, but you can created hidden members. If I remember correctly, MS uses a similar method when you create a window - there is hidden data.

The following is just off the top of my head and does not represent an actual implementation.

/* In ExpContainer.h */

/* this is one possibility for a handle */
#define EXPHANDLE void*

EXPHANDLE ExpContainer_Create(size_t data_size, size_t count);
void ExpContainerDestroy(EXPHANDLE hExpContainer);
size_t ExpContainer_Insert(EXPHANDLE hExpContainer, void*, size_t pos);
size_t ExpContainer_Append(EXPHANDLE hExpContainer, void*); // or push_back
/* etc. */

/* In ExpContainer.c */

/* example container */
struct ExpContainer
{
    /* hidden data can be anything you wish */
    size_t data_size_; /* size passed as argument to create method */
    size_t size_; /* current number data_size_ elements space allocated */
    size_t used_; /* current number of elements */
    void* data_;  /* just one possibility for storage */

    /* the handle/pointer will be pointing to this value */
    unsigned signature_; /* in case you want handle validation */
};

EXPHANDLE ExpContainer_Create(size_t data_size, size_t count);
{
   /* create a new container */
   struct ExpContainer* pContainer = malloc(sizeof(struct ExpContainer));

   /* continue with other initiation */

   /* return a handle to the user */
   return (EXPHANDLE)(pContainer  + offsetof(signature_));
}

INTP
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone

GeneralRe: Popularity Of C among developer Pin
jschell21-Apr-19 8:46
memberjschell21-Apr-19 8:46 
AnswerRe: Popularity Of C among developer Pin
jschell21-Apr-19 8:35
memberjschell21-Apr-19 8:35 
QuestionGet menu color in MFC feature pack Pin
_Flaviu14-Apr-19 0:26
member_Flaviu14-Apr-19 0:26 
Question"Debug Assertion Failed at line: 252 in viewcore.CPP" Pin
manoharbalu10-Apr-19 19:21
membermanoharbalu10-Apr-19 19:21 
AnswerRe: "Debug Assertion Failed at line: 252 in viewcore.CPP" Pin
Victor Nijegorodov10-Apr-19 21:58
memberVictor Nijegorodov10-Apr-19 21:58 
QuestionRe: "Debug Assertion Failed at line: 252 in viewcore.CPP" Pin
David Crow11-Apr-19 11:33
memberDavid Crow11-Apr-19 11:33 
QuestionProblem when I run the application using cntrl+F5. Wintech OPC DLL Pin
D.Manivelan8-Apr-19 5:02
memberD.Manivelan8-Apr-19 5:02 
AnswerRe: Problem when I run the application using cntrl+F5. Wintech OPC DLL Pin
11917640 Member 9-Apr-19 23:57
member11917640 Member 9-Apr-19 23:57 
GeneralRe: Problem when I run the application using cntrl+F5. Wintech OPC DLL Pin
D.Manivelan10-Apr-19 20:04
memberD.Manivelan10-Apr-19 20:04 
GeneralRe: Problem when I run the application using cntrl+F5. Wintech OPC DLL Pin
Victor Nijegorodov10-Apr-19 21:55
memberVictor Nijegorodov10-Apr-19 21:55 
QuestionClass as memebrs of other classes : Create a constructor that takes all data Pin
desanti6-Apr-19 8:09
memberdesanti6-Apr-19 8:09 
AnswerRe: Class as memebrs of other classes : Create a constructor that takes all data Pin
k50546-Apr-19 10:40
memberk50546-Apr-19 10:40 
GeneralRe: Class as memebrs of other classes : Create a constructor that takes all data Pin
Stefan_Lang8-Apr-19 22:51
memberStefan_Lang8-Apr-19 22:51 
AnswerRe: Class as memebrs of other classes : Create a constructor that takes all data Pin
Gerry Schmitz6-Apr-19 11:36
mveGerry Schmitz6-Apr-19 11:36 
AnswerRe: Class as memebrs of other classes : Create a constructor that takes all data Pin
jschell7-Apr-19 9:53
memberjschell7-Apr-19 9:53 
QuestionNew [[nodiscard]] attribute usage. Pin
Maximilien4-Apr-19 6:57
memberMaximilien4-Apr-19 6:57 
AnswerRe: New [[nodiscard]] attribute usage. Pin
John R. Shaw4-Apr-19 8:56
memberJohn R. Shaw4-Apr-19 8:56 

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.