Advertisement Jump to content
Sign in to follow this  

Basic C++ header/implementation problem

This topic is 3336 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So I'm having a brain fart as to why these two files are not compiling. Header File:
#pragma once

class Material
    virtual ~Material();

    void SetDiffuse(float r, float g, float b);
    void SetAmbient(float r, float g, float b);
    void SetSpecular(float r, float g, float b, float pow);
    void SetEmissive(float r, float g, float b);
    HRESULT Update();

    D3DMATERIAL9 material;

Source File:
#include "material.h"
#include "DXUT.h"

    ZeroMemory(&material, sizeof(D3DMATERIAL9));
    material.Diffuse.r = 1.0f;
The error I get is: material.cpp(4) : error C2653: 'Material' : is not a class or namespace name What confused me is that intellisense in VS sees that material is a member of the class Material. I don't understand why this wont compile. Also, when I implement this constructor in the header file right below the Class declaration, it works. :| I gather there's a problem with the include "Material.h" This is embarrassing.

Share this post

Link to post
Share on other sites
The code that you posted would indicate that you are trying to declare a class with members/functions that have types defined in the d3d and windows headers.
Try putting your #include "DXUT.h" before the #include "Material.h"

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!