J'ai 2 en-têtes et un fichier cpp. Block.h :
#ifndef BLOCK_H
#define BLOCK_H
namespace storage {
class Block {
};
} // namespace storage
#endif // BLOCK_H
PerformanceWriteTest.h
#ifndef _PERFORMANCE_WRITE_TEST_
#define _PERFORMANCE_WRITE_TEST_
#include <string>
#include <vector>
using std::vector;
class Block; // <<< Forward declaration of Block
class PerformanceWriteTest {
vector<Block*> blocks_;
public:
virtual ~PerformanceWriteTest();
};
#endif
PerformanceWriteTest.cpp
#include "Block.h"
#include "PerformanceWriteTest.h"
using storage::Block; // <<< Use the scope storage::Block. Error!
PerformanceWriteTest::~PerformanceWriteTest() {
for (Block* block : blocks_) {
delete block;
}
}
Visual Studio 2012 me donne l'erreur : error C2874 : using-declaration causes a multiple declaration of 'storage::Block'.
Est-il possible d'éviter cette erreur sans déplacer la directive using et inclure "Block.h" dans l'en-tête ?