{"id":200,"date":"2019-01-15T00:00:10","date_gmt":"2019-01-15T08:00:10","guid":{"rendered":"http:\/\/35.243.195.209\/?p=200"},"modified":"2019-01-15T00:00:10","modified_gmt":"2019-01-15T08:00:10","slug":"class-not-declared-in-scope-with-h-included","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2019\/01\/15\/class-not-declared-in-scope-with-h-included\/","title":{"rendered":"Class not Declared in Scope with .h Included"},"content":{"rendered":"<h2>Summary<\/h2>\n<p>I come across a compiling error, in which it says <code>class A<\/code> was not declared. However, I actually include <code>A.h<\/code>.<\/p>\n<h2>Details<\/h2>\n<p>After some research, I find out the bugs. In <code>utils.h<\/code>, I want to use some static member varible in <code>class A<\/code> and thus I include <code>A.h<\/code>. However, since <code>utils.h<\/code> acts as its name, I also include <code>utils.h<\/code> in <code>A.h<\/code>.<\/p>\n<p>Then say in <code>foo.cpp<\/code>, I include <code>A.h<\/code> since I want to use the <code>class A<\/code>. But <code>A.h<\/code> includes <code>utils.h<\/code> then <code>utils.h<\/code> tries to include <code>A.h<\/code> but the include guard blocks that, which causes that <code>class A<\/code> was not declared in <code>utils.h<\/code>.<\/p>\n<p>As a solution, I make that <code>utils.h<\/code> as independent as possible, and it does not include other user-defined classes (that&#8217;s what <strong>utils<\/strong> mean).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary I come across a compiling error, in which it says class A was not declared. However, I actually include A.h. Details After some research, I find out the bugs. In utils.h, I want to use some static member varible in class A and thus I include A.h. However, since utils.h acts as its name,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,5],"tags":[],"class_list":["post-200","post","type-post","status-publish","format-standard","hentry","category-c","category-proglang"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/200","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=200"}],"version-history":[{"count":2,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/200\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/200\/revisions\/202"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=200"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=200"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=200"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}