Namespace error

Prayas Bharadwaj 1 Reputation point
2020-10-21T03:26:17.327+00:00

I am beginner to C++

I have been writing a simple library defined in my own namespace core but when I using namespace core; , Visual Studio throws errors
33864-filees.png

These are my files

33934-code.png

This is the code

33943-errors.png

These are the errors

Developer technologies C++
{count} votes

1 answer

Sort by: Most helpful
  1. Guido Franzke 2,191 Reputation points
    2020-10-21T06:02:04.537+00:00

    Hello,
    you must include the header file of your namespace core. using core is not enough. In addition you use the scope operator :: , so you don't need the using core line.
    If your namespace is declared in your file "Namespace.h", then you must include this file:

    #include "Namespace.h"
    //using namespace core;
    int main() { ...
    

    Read this:
    c_header_files.htm
    how-to-use-include-directive-correctly

    Regards, Guido

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.