Click here to Skip to main content
15,923,689 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to Resize Static Window Objects Pin
Richard MacCutchan10-Mar-13 23:29
mveRichard MacCutchan10-Mar-13 23:29 
GeneralRe: How to Resize Static Window Objects Pin
Richard Andrew x6411-Mar-13 2:13
professionalRichard Andrew x6411-Mar-13 2:13 
GeneralRe: How to Resize Static Window Objects Pin
Richard MacCutchan11-Mar-13 2:47
mveRichard MacCutchan11-Mar-13 2:47 
QuestionWhy moniker? Pin
Vaclav_10-Mar-13 5:46
Vaclav_10-Mar-13 5:46 
AnswerRe: Why moniker? Pin
dusty_dex10-Mar-13 6:45
dusty_dex10-Mar-13 6:45 
GeneralRe: Why moniker? Pin
Vaclav_10-Mar-13 7:25
Vaclav_10-Mar-13 7:25 
GeneralRe: Why moniker? Pin
dusty_dex10-Mar-13 7:32
dusty_dex10-Mar-13 7:32 
Joke[Challenge/Puzzle] Implement reinterpret_cast Pin
MicroVirus10-Mar-13 3:55
MicroVirus10-Mar-13 3:55 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Richard MacCutchan10-Mar-13 8:07
mveRichard MacCutchan10-Mar-13 8:07 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
MicroVirus10-Mar-13 10:57
MicroVirus10-Mar-13 10:57 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Brandon-X1200010-Mar-13 11:32
Brandon-X1200010-Mar-13 11:32 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Richard MacCutchan10-Mar-13 23:17
mveRichard MacCutchan10-Mar-13 23:17 
AnswerRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Matthew Faithfull11-Mar-13 1:44
Matthew Faithfull11-Mar-13 1:44 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Stefan_Lang11-Mar-13 23:18
Stefan_Lang11-Mar-13 23:18 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Matthew Faithfull11-Mar-13 23:40
Matthew Faithfull11-Mar-13 23:40 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
MicroVirus13-Mar-13 11:12
MicroVirus13-Mar-13 11:12 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Matthew Faithfull13-Mar-13 11:18
Matthew Faithfull13-Mar-13 11:18 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
MicroVirus13-Mar-13 11:29
MicroVirus13-Mar-13 11:29 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Stefan_Lang11-Mar-13 3:29
Stefan_Lang11-Mar-13 3:29 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
harold aptroot11-Mar-13 9:03
harold aptroot11-Mar-13 9:03 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Stefan_Lang11-Mar-13 22:30
Stefan_Lang11-Mar-13 22:30 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Stefan_Lang12-Mar-13 0:09
Stefan_Lang12-Mar-13 0:09 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
MicroVirus13-Mar-13 11:19
MicroVirus13-Mar-13 11:19 
GeneralRe: [Challenge/Puzzle] Implement reinterpret_cast Pin
Stefan_Lang13-Mar-13 23:07
Stefan_Lang13-Mar-13 23:07 
Originally my idea was to use a struct of function pointers and 'iterate' over them to arrive at a different pointer. However, I found that pointer arithmetic apparently doesn't work on function pointers. Frown | :( That is when I thought of union. It was only later that I realized the union construct can solve the task by itself. But since I already posted my solution, there was no point in 'watering it down'. Wink | ;)

Another thing I thought of is overloading virtual functions with different return types. But it would require at least a downcast of the instance pointer:
C++
class base {
public:
   virtual ~base() {}
   virtual int* foo(int i) { return &i; }
};
class derived : public base {
public:
   virtual ~derived() {}
   virtual int foo(int i) { return i; } // overrides base::foo()
};
int* bar(int i) {
   base* caster = new derived; // implicit downcast here
   int* pi = caster->foo(i); // this is the actual 'reinterpret cast'
   delete caster;
   return pi:
}

I wonder if I could get this to work if I put part of the code inside a constructor, before the construction of the vtable - but then the behaviour would be undefined D'Oh! | :doh:
Questiontinyxml Pin
venkatesh528678-Mar-13 16:43
venkatesh528678-Mar-13 16:43 

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.