Jump to content
  • Advertisement
Sign in to follow this  
kibokun

Basic C++ header/implementation problem

This topic is 3182 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
{
public:
    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();

protected:
    D3DMATERIAL9 material;


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

Material::Material()
{
    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
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!