Nicht deklarierte Bezeichner (error C2065) in c++

Ich bin Implementierung einer header-Datei "IVideoPlayer.h" und ich erstellt habe eine abstrakte Klasse "IVideoPlayer".

class IVideoPlayer
{

public:
//Initialization
virtual bool Load(const char* pFilePath, bool useSubtitles = false) = 0;
    virtual bool Start() = 0;
    virtual bool Stop() = 0;
    //....
};

Und die Funktionen sind definiert in der Datei "VideoPlayer.cpp"

#include "stdafx.h"
#include "IVideoPlayer.h"
#include <dshow.h>


HRESULT hr = CoInitialize(NULL);
IGraphBuilder *pGraph = NULL;
IMediaControl *pControl = NULL;
IMediaEvent   *pEvent = NULL;

class VideoPlayer:public IVideoPlayer
{
public:

    bool Load(const char* pFilePath, bool useSubtitles = false)
    {
        EPlaybackStatus var1 = PBS_ERROR;
        //Initialize the COM library.

        if (FAILED(hr))
        {
            printf("ERROR - Could not initialize COM library");
            return 0;
        }

        //Create the filter graph manager and query for interfaces.
    hr = CoCreateInstance(CLSID_FilterGraph, NULL, CLSCTX_INPROC_SERVER, 
            IID_IGraphBuilder, (void **)&pGraph);
        if (FAILED(hr))
        {
        printf("ERROR - Could not create the Filter Graph Manager.");
            return 0;
        }

        hr = pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);
        hr = pGraph->QueryInterface(IID_IMediaEvent, (void **)&pEvent);

        //Build the graph. IMPORTANT: Change this string to a file on your system.
        hr = pGraph->RenderFile(L"G:\edit.wmv", NULL);
        return 0;

    }

    bool Start()
    {
        if (SUCCEEDED(hr))
        {
            //Run the graph.
            hr = pControl->Run();
            if (SUCCEEDED(hr))
            {
                //Wait for completion.
                long evCode;
                pEvent->WaitForCompletion(INFINITE, &evCode);

        //Note: Do not use INFINITE in a real application, because it
                //can block indefinitely.
            }
        }
        return 0;

    }

    bool Stop()
    {
        pControl->Release();
        pEvent->Release();
        pGraph->Release();
        CoUninitialize();
        return 0;

    }
};

Sowie zum überprüfen der header-Datei, die ich erstellt habe-Datei sample.cpp

#include "stdafx.h"
#include "IVideoPlayer.h"
#include <stdio.h>
#include <conio.h>



int main(void)
{
VideoPlayer h;
h.Load("G:\hila.wmv");
getch();
return 0;
}

Den Fehler:

Error   1 error C2065: 'VideoPlayer' : undeclared identifier    
Error   2 error C2146: syntax error : missing ';' before identifier 'h' 
Error   3 error C2065: 'h' : undeclared identifier  
Error   4 error C2065: 'h' : undeclared identifier  
Error   5 error C2228: left of '.Load' must have class/struct/union 

Warum compiler zeigt es als nicht deklarierte Bezeichner?
Jede Hilfe wird akzeptiert. Danken Ihnen im Voraus

  • Warum schreibst du using namespace std; wenn Sie sich nicht selbst mit so etwas aus c++ - Bibliotheken?? Auch dies sollte nicht getan werden, im Allgemeinen!
  • fügen Sie #include "resource.h"
InformationsquelleAutor user3615925 | 2014-05-08
Schreibe einen Kommentar