ventaquil
ventaquil

Reputation: 2848

Visual Studio missing ; before *

I'm working on Blake algorithm in Visual but I have small problem.

My Block.h file

#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

#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 '*'

I'm newby in C++ and I can't find error. In Stack I found solutions like missing ; after class declaration, but I have semicolons.

Upvotes: 1

Views: 654

Answers (1)

marcinj
marcinj

Reputation: 49986

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.

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); would compile.

Upvotes: 4

Related Questions