[英]Visual Studio missing ; before *
I'm working on Blake algorithm in Visual but I have small problem. 我正在Visual中研究Blake算法,但是我有一个小问题。
My Block.h
file 我的
Block.h
文件
#pragma once
#include<string>
#include<bitset>
#include<iostream> // DEBUG
#include"BlocksContainer.h"
using namespace std;
class Block {
public:
static void CreateBlocks(string);
static string CreatePadding(int);
Block(string);
protected:
string BlockContent;
};
My BlocksContainer.h
file 我的
BlocksContainer.h
文件
#pragma once
#include"Block.h"
class BlocksContainer {
public:
int GetLength(void);
Block* GetNBlock(int);
BlocksContainer(Block**, int);
protected:
Block** Blocks;
int Length;
};
I don't know why but Visual throw me blockscontainer.h(7): error C2143: syntax error : missing ';' before '*'
我不知道为什么,但是Visual扔给我
blockscontainer.h(7): error C2143: syntax error : missing ';' before '*'
blockscontainer.h(7): error C2143: syntax error : missing ';' before '*'
I'm newby in C++ and I can't find error. 我是C ++中的newby,找不到错误。 In Stack I found solutions like missing
;
在Stack中,我发现了缺少的解决方案
;
after class declaration, but I have semicolons. 在类声明之后,但是我有分号。
You dont need: 您不需要:
#include"BlocksContainer.h"
inside block.h, this line causes Block to be undefined inside BlocksContainer.h because it was not yet visible to compiler. 在block.h内部,此行导致Block在BlocksContainer.h内部未定义,因为编译器尚未看到它。
In case you really need such inter dependent headers you can declare class like this: 如果确实需要此类相互依赖的标头,则可以这样声明类:
class Block;
after such statement you are allowed to use Block class but only in compound statements like pointers or references - that means Block* GetNBlock(int);
在这样的语句之后,您被允许使用Block类,但只能在复合语句(如指针或引用)中使用-这意味着
Block* GetNBlock(int);
would compile. 会编译。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.