{"id":785,"date":"2022-08-30T15:07:08","date_gmt":"2022-08-30T15:07:08","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/struct-is-not-visible-to-cpp-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:07:08","modified_gmt":"2022-08-30T15:07:08","slug":"struct-is-not-visible-to-cpp-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/struct-is-not-visible-to-cpp-collection-of-common-programming-errors\/","title":{"rendered":"Struct is not visible to .cpp-Collection of common programming errors"},"content":{"rendered":"<p>I declared a struct at header file, you can see it below.<\/p>\n<pre><code>private: \n    struct Node{\n        Customer data;\n        Node *next;\n        Node *prev;\n    };\nNode* find (const int index) const;\n<\/code><\/pre>\n<p>And declared a function that returns <code>Node*<\/code> private.<\/p>\n<p>However when I try to implement the function <code>find<\/code> at my cpp file, it gives an error saying that &#8220;<strong>identifier Node is undefined<\/strong>&#8220;.<\/p>\n<pre><code>Node* CustomerList::find(const int index){\n    \/\/some random code\n}\n<\/code><\/pre>\n<p>What is the problem, isn&#8217;t <code>Node<\/code> supposed to be visible to the .cpp ?<\/p>\n<ol>\n<li>\n<p>Assuming <code>CustomerList<\/code> is the class containing <code>Node<\/code>.<\/p>\n<pre><code>CustomerList::Node* CustomerList::find(const int index){\n    \/\/some random code\n}\n<\/code><\/pre>\n<p>Within a <code>CustomerList<\/code> method you can just say <code>Node<\/code> but the return type is different, you still need to qualify with <code>CustomerList::<\/code><\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:44:29. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I declared a struct at header file, you can see it below. private: struct Node{ Customer data; Node *next; Node *prev; }; Node* find (const int index) const; And declared a function that returns Node* private. However when I try to implement the function find at my cpp file, it gives an error saying that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-785","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=785"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/785\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}