Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:45:13+00:00 2026-05-23T18:45:13+00:00

I asked this question recently: create a namespace in c++/cli? and so I am

  • 0

I asked this question recently: create a namespace in c++/cli?
and so I am trying to create my own namespace in c++/cli.

But when I use the same namespace in two separate files (.cpp), the namespace is clearly not recognized as being the same because I get errors when I try to reference the other class in the other file.

Here’s basically what I have:

Pets.cpp:

namespace Animals
   {
   public ref class Pets 
     {
     public:
        List<Dog> ^vDogs;

     Pets::Pets()
        {
        vDogs = gcnew List<Dog^>();
        }

     void Pets::DoSomething()
        {
        }
     };
   }

Dog.cpp:

namespace Animals
   {
   public ref class Dog 
     {

     Dog::Dog()
        {
        }

     void Dog::DoSomething()
        {
        }
     };
   }

Other information:

1) Files are in the same folder

2) Files were added to an existing solution in a different folder

3) I also tried using namespace Animals in either file but I get an error saying namespace does not exist.

4) I am using Visual Studio 2010 (fyi in case someone has a way to fix but I need to do something specific in VS)

So my question is: What do I need to do in order for the namespace to be recognized?

Please let me know what other information is needed in order for the problem to be solved.

Thanks in advance for your time and patience! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:45:13+00:00Added an answer on May 23, 2026 at 6:45 pm

    The C++/CLI compiler is stuck with the build model of traditional C and C++ compilers. Formulated at a time when a kilobyte of memory took as much space as a shoebox. It is a single-pass compiler that processes one .cpp file at a time. With a linker to glue the bits together.

    Which means that you’ll have to use traditional header files to declare your classes and the #include directive at the top of your source code file to include it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok I had asked a question recently based on this. But I need to
I was recently asked this question in an interview: There are two arrays of
I recently asked this question in the pyglet-users group, but got response, so I'm
Very recently I've asked this question, but wasn unable to fix this. So I
Further to this question and this one that I asked more recently but without
I recently asked this question , but after some of the responses and some
I recently asked this question: Expose XML or Objects - thanks all for the
I recently asked this question and worked out that the reason a single email
I recently asked this question: MS SQL share identity seed amongst tables (Many people
This question is related to this other question I recently asked... cf.net exception and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.