I get the error error C2514: 'BLOCK' : CLASS HAS NO CONSTRUCTOR
with a simple class like this:
BLOCK.h
#pragma once
#include "helpful.h"
class WORLD;
class BLOCK
{
public:
short int type;
void Render();
BLOCK();
~BLOCK(void);
};
BLOCK.cpp
#include "BLOCK.h"
#include "WORLD.h"
BLOCK::BLOCK(void)
{
}
void BLOCK::Render()
{
}
BLOCK::~BLOCK(void)
{
}
But the BLOCK
开发者_运维百科 class is defined, no?
I found my mistake: The call to BLOCK
's constructor was in another file, but the header for BLOCK
wasn't included, all I had was class BLOCK;
. Changed it instead to #include BLOCK.h
, problem solved.
You need to look for it in MYCLASS
According to MSDN, error C2514 is raised when:
The class, structure, or union has no constructor with a parameter list that matches the parameters being used to instantiate it.
My guess is that you're not passing the right parameters to your class' constructor. The code that raised the error is obviously not part of what you have shown.
精彩评论