Click here to Skip to main content
15,843,728 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
So if that is the case you have a structural problem in how you organized code. However don't panic first get the
code running and the easy way to do that is pass the whole class in to functions as a pointer .. it's only 4 bytes.

You can pass the class pointer freely into another class lets say USBD needs HCD
void USBD:: SomeFuncThatNeedsHCD (HCD* hcd){
    hcd->SomeHCDFunction();
}

or you can pass it to a static code block, lets say some static block needs HCD access
static void SomeStaticCodeWhoAccessHCD (HCD* hcd){
    hcd->SomeHCDFunction();
}


As I said it's a symptom of a structural problem but a class is nothing more than a fancy struct it is
legal to pass the class around as a pointer just like you did the original struct ... We just frown on it Smile | :)

Yes you can even pass the class pointer to an interrupt just make sure it is valid before the ISR uses.
That usually means set it to NULL and the ISR checks for a non NULL value before it uses.
In vino veritas

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 
AnswerRe: Object Creation of an class? Pin
Midi_Mick11-Oct-16 23:13
professionalMidi_Mick11-Oct-16 23:13 
GeneralRe: Object Creation of an class? Pin
Mathan_CodeProject12-Oct-16 0:01
Mathan_CodeProject12-Oct-16 0:01 
QuestionC++ syntax Pin
Ratul Thakur10-Oct-16 22:35
Ratul Thakur10-Oct-16 22:35 
AnswerRe: C++ syntax Pin
CPallini10-Oct-16 22:49
mveCPallini10-Oct-16 22:49 

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.