I have a solution consisting of two projects:
Project1
containing a single file program.cpp
namespace Program1 {
void foo() { ... }
}
Project2
containing another single file program.cpp in which I’d like to call foo()
namespace Program2 {
void bar() { Program1::foo() }
}
I have set:
- project dependencies (Program2 depends on Program1)
- references in Program2 to Program1
But still I recieve an error
error C2653: 'Program1' : is not a class or namespace name
What else do I need to do to call Program1::foo() in Project2?
You need to include the header file which contains the declaration:
Project1 – Program.h
Project2 – Program.cpp