开发者

error C2514: 'BLOCK' : CLASS HAS NO CONSTRUCTOR

开发者 https://www.devze.com 2023-02-06 17:53 出处:网络
I get the error error C2514: \'BLOCK\' : CLASS HAS NO CONSTRUCTORwith a simple class like this: BLOCK.h

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号