Click here to Skip to main content
15,847,077 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to invoke Printing Preferences for the given Printer programmatically? Pin
purnachandra505016-Oct-16 18:48
purnachandra505016-Oct-16 18:48 
SuggestionRe: How to invoke invoke Printing Preferences for the given Printer programmatically? Pin
Richard MacCutchan17-Oct-16 6:06
mveRichard MacCutchan17-Oct-16 6:06 
QuestionHelp please Memoized rod cutting in C while showing the length it is cut Pin
Member 1279667016-Oct-16 13:03
Member 1279667016-Oct-16 13:03 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
leon de boer16-Oct-16 17:12
leon de boer16-Oct-16 17:12 
GeneralRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan17-Oct-16 6:08
mveRichard MacCutchan17-Oct-16 6:08 
AnswerRe: Help please Memoized rod cutting in C while showing the length it is cut Pin
Richard MacCutchan16-Oct-16 22:25
mveRichard MacCutchan16-Oct-16 22:25 
QuestionAssigning pointers from one class to another and Pin
Vaclav_14-Oct-16 7:23
Vaclav_14-Oct-16 7:23 
AnswerRe: Assigning pointers from one class to another and Pin
leon de boer14-Oct-16 18:58
leon de boer14-Oct-16 18:58 
You keep doing this over and over .. think about it

A_USBD::USBD_GetDeviceDescriptorBegin IS NOT AND NEVER WILL be a "void (*) void" function.
It's a class member function and so it will be a "USBD::void(*)void"

If you need to check stuff the search string "Member function pointer" will get you what you need.

However I strongly advise you to stop and think for a minute before you start passing member
function pointers around. If you need to do this a lot you might as well pass the whole class
in as a pointer it is only 4 bytes and save the effort.

Here lets cross connect both classes via class instance pointers
// You will need the forward declares
class USDB;
class HCD;

class USBD {
public:
	void ConnectHCD (HCD* hcd);   // Connect a HCD pointer into a USBD
    void SomeFunction (void);    // Some test function

	HCD* ConnectedHCD; // Pointer to connected buddy class it will be NULL after construction
};

class HCD {
public:
	void ConnectUSBD (USBD* usbd); // Connect a USBD into a HCD

	USBD* ConnectedUSBD; // Pointer to connected buddy class it will be NULL after construction
};

/* Simply hold given HCD pointer .. allows connectedHCD to be private if you want */
void USBD::ConnectHCD (HCD* hcd) {
	ConnectedHCD = hcd;
}

/* Our test function */
void USBD::SomeFunction (void){ 
}

/* Simply hold given USBD pointer ... allows connectedUSBD to be private if you want */
void HCD::ConnectUSBD (USBD* usbd) {
	ConnectedUSBD = usbd;
}

// SO LETS USE IT IN YOUR CODE

/* First we create our class objects */ 
USBD usbd;    // Create a usbd
HCD hcd;      // Create a hcd

/* Then we connect them */
usbd.ConnectHCD(&hcd);  // Connect the created hcd as a pointer into usbd
hcd.ConnectUSBD(&usbd); // Connect the created usbd as a pointer into hcd

// Done you may now freely use the each class inside the other using the pointer
// Dead simple and get around all the mess you are doing .. so lets do one
hcd.ConnectedUSBD->SomeFunction();  // Just call it via the the pointer

See each class can freely use it's connect buddy via the connected pointer.

You just need to remember to connect them before you ever attempt to use them as
the pointers will always start as null until set.

Usually if you have to do this you have a basic design flaw but you can do it.
In vino veritas


modified 15-Oct-16 0:38am.

GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 3:24
Vaclav_15-Oct-16 3:24 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 5:42
leon de boer15-Oct-16 5:42 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_15-Oct-16 7:12
Vaclav_15-Oct-16 7:12 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer15-Oct-16 18:16
leon de boer15-Oct-16 18:16 
GeneralRe: Assigning pointers from one class to another and Pin
Vaclav_19-Oct-16 5:54
Vaclav_19-Oct-16 5:54 
GeneralRe: Assigning pointers from one class to another and Pin
leon de boer19-Oct-16 8:45
leon de boer19-Oct-16 8:45 
NewsHow to provide a Security to a proprietary software or presemtation. Pin
Member 1278313512-Oct-16 21:03
Member 1278313512-Oct-16 21:03 
GeneralRe: How to provide a Security to a proprietary software or presemtation. Pin
jeron113-Oct-16 5:15
jeron113-Oct-16 5:15 
GeneralRe: How to provide a Security to a proprietary software or presemtation. Pin
leon de boer13-Oct-16 9:17
leon de boer13-Oct-16 9:17 
Questionclass is missing "type" - why ? Pin
Vaclav_12-Oct-16 16:00
Vaclav_12-Oct-16 16:00 
AnswerRe: class is missing "type" - why ? Pin
leon de boer12-Oct-16 18:45
leon de boer12-Oct-16 18:45 
AnswerRe: class is missing "type" - why ? Pin
Graham Breach13-Oct-16 0:11
Graham Breach13-Oct-16 0:11 
QuestionObject Creation of an class? Pin
Mathan_CodeProject11-Oct-16 6:17
Mathan_CodeProject11-Oct-16 6:17 
AnsweralternatRe: Object Creation of an class? Pin
leon de boer11-Oct-16 6:50
leon de boer11-Oct-16 6:50 
GeneralRe: alternatRe: Object Creation of an class? Pin
Mathan_CodeProject12-Oct-16 0:02
Mathan_CodeProject12-Oct-16 0:02 
AnswerRe: Object Creation of an class? Pin
Krishnakumartg11-Oct-16 20:46
Krishnakumartg11-Oct-16 20:46 
GeneralRe: Object Creation of an class? Pin
Mathan_CodeProject12-Oct-16 0:01
Mathan_CodeProject12-Oct-16 0:01 

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.