Header 1 includes Header 2 Which Includes Header 1, How to solve?

Started by
11 comments, last by silvermace 19 years, 6 months ago
Quote:Original post by Mussi
You could also do:

#pragma once

instead of:

#ifndef HEADER
#define HEADER

// header file contents

#endif


Yes, you could use #pragma once instead of include guards if you want to write invalid C++ code.
Advertisement
sounds like you need a forward declartion here
// ********* header2.hclass A {  ...};// ********* header1.hclass A;class B {public:   void foo(A *lpA);};


"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website
Quote:Original post by Mussi
You could also do:

#pragma once

instead of:

#ifndef HEADER
#define HEADER

// header file contents

#endif


pragma once does not guarantee that the file will not get included again, it simply guarantees that the preprocessor will not read the file again.
"I am a donut! Ask not how many tris/batch, but rather how many batches/frame!" -- Matthias Wloka & Richard Huddy, (GDC, DirectX 9 Performance)

http://www.silvermace.com/ -- My personal website

This topic is closed to new replies.

Advertisement