Click here to Skip to main content
16,007,814 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Bit-Shifting - What is it? Pin
Rick York12-Feb-02 6:52
mveRick York12-Feb-02 6:52 
AnswerRe: Bit-Shifting - What is it? Pin
User 665812-Feb-02 7:02
User 665812-Feb-02 7:02 
GeneralRe: Bit-Shifting - What is it? Pin
Joaquín M López Muñoz12-Feb-02 7:05
Joaquín M López Muñoz12-Feb-02 7:05 
GeneralRe: Bit-Shifting - What is it? Pin
Nemanja Trifunovic12-Feb-02 7:08
Nemanja Trifunovic12-Feb-02 7:08 
GeneralRe: Bit-Shifting - What is it? Pin
Joaquín M López Muñoz12-Feb-02 7:11
Joaquín M López Muñoz12-Feb-02 7:11 
GeneralRe: Bit-Shifting - What is it? Pin
Nemanja Trifunovic12-Feb-02 7:07
Nemanja Trifunovic12-Feb-02 7:07 
AnswerRe: Bit-Shifting - What is it? Pin
12-Feb-02 8:17
suss12-Feb-02 8:17 
Generalstatic_cast error Pin
RobJones12-Feb-02 6:30
RobJones12-Feb-02 6:30 
Hello,
Can anyone tell me why I get this error?

error:
error C2243: 'static_cast' : conversion from 'class IStopwatch *' to 'struct IUnknown *' exists, but is inaccessible

Here is the code:
<pre>
HRESULT __stdcall CStopwatch::QueryInterface(REFIID riid, void **ppvObject)
{
HRESULT hr = S_OK;

if(riid == IID_IUnknown)
*ppvObject = static_cast<IUnknown*>(static_cast<IStopwatch*>(this)); <-- error
else if (riid == IID_IStopwatch)
*ppvObject = static_cast<IStopwatch*>(this);
else
{
ppvObject = NULL;
hr = E_NOINTERFACE;
}

if(SUCCEEDED(hr))
(static_cast<IUnknown*>(*ppvObject))->AddRef();

return hr;
}
</pre>

Here is my header:

<pre>
#if !defined(AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_)
#define AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <windows.h>

class IStopwatch : IUnknown
{
public:
//IStopwatch specific functions
virtual HRESULT __stdcall Start() = 0;
virtual HRESULT __stdcall ElapsedTime(float *Time) = 0;
};

class CStopwatch : public IStopwatch
{
public:
CStopwatch();
virtual ~CStopwatch();

private:
// The frequency of the counter
// returned by QueryPerformanceCounter()
LARGE_INTEGER m_nFrequency;

// The counter value when the start method was last called.
LARGE_INTEGER m_nStartTime;

public:
// IUnknown methods
HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject);
unsigned long __stdcall AddRef();
unsigned long __stdcall Release();

// IStopwatch specific functions
HRESULT __stdcall Start();
HRESULT __stdcall ElapsedTime(float *Time);
};

#endif // !defined(AFX_STOPWATCH_H__CF2EC9CF_CCAA_4708_8320_0B5A054E3876__INCLUDED_)
</pre>

Thanks,
Rob
GeneralRe: static_cast error Pin
pba_12-Feb-02 6:38
pba_12-Feb-02 6:38 
GeneralRe: static_cast error Pin
RobJones12-Feb-02 6:48
RobJones12-Feb-02 6:48 
GeneralOne simple question => Pin
12-Feb-02 4:39
suss12-Feb-02 4:39 
GeneralRe: One simple question => Pin
Ravi Bhavnani12-Feb-02 5:08
professionalRavi Bhavnani12-Feb-02 5:08 
GeneralRe: One simple question => Pin
12-Feb-02 5:21
suss12-Feb-02 5:21 
GeneralRe: One simple question => Pin
Kashif Manzoor12-Feb-02 5:41
Kashif Manzoor12-Feb-02 5:41 
GeneralThanx Pin
12-Feb-02 22:24
suss12-Feb-02 22:24 
GeneralGrouping Data Pin
12-Feb-02 4:31
suss12-Feb-02 4:31 
GeneralRe: Grouping Data Pin
Mazdak12-Feb-02 4:39
Mazdak12-Feb-02 4:39 
Generalproblem opening files in application Pin
Stew12-Feb-02 4:21
Stew12-Feb-02 4:21 
GeneralRe: problem opening files in application Pin
Nish Nishant12-Feb-02 5:16
sitebuilderNish Nishant12-Feb-02 5:16 
GeneralRe: problem opening files in application Pin
12-Feb-02 7:03
suss12-Feb-02 7:03 
GeneralMs Word Automation and ActiveX Pin
Braulio Dez12-Feb-02 3:48
Braulio Dez12-Feb-02 3:48 
QuestionHow to remove this small error with sprintf Pin
tppradeep1812-Feb-02 1:26
tppradeep1812-Feb-02 1:26 
AnswerRe: How to remove this small error with sprintf Pin
Christian Graus12-Feb-02 1:33
protectorChristian Graus12-Feb-02 1:33 
GeneralRe: How to remove this small error with sprintf Pin
tppradeep1812-Feb-02 1:43
tppradeep1812-Feb-02 1:43 
AnswerRe: How to remove this small error with sprintf Pin
Kashif Manzoor12-Feb-02 2:01
Kashif Manzoor12-Feb-02 2: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.