.cpp files aren't (shouldn't be) included ever, so they don't need include guards...
This line: TEST::MyStaticClass msc; where did this come from? There is no class in the TEST namespace called MyStaticClass.
Including the header gives you the definition of the class, but all the functions only have declarations and are not defined. The cpp file has all the definitions - you'll have to figure out how you want to solve this problem (do not include the cpp file!)
- add reference to CppTest
- add using TEST; on top of MyUnitTest.cs file (not even necessary)
Therefore I tried the following in C++:
- add reference to CppTest
- add #include "../CppTest/MyStaticClass.h" on top of MyUnitTest.cpp
Unfortunately this doesn't work...
As you can see CppTest itself compiles... I now just want to add some unit test. I created a new project and now I just want to use MyStaticClass which is defined in CppTest. Do I have to add CppTest to the linker-dependencies??
It's not a library or a DLL, you're including a header file as if it were part of your project. Here is an example of a class with inline functions:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
class MyClass
{
int value;
public:
MyClass() : value(0) {}
MyClass(constint &from) : value(from) {}
MyClass(const MyClass &from) : value(from.value) {}
void SetValue(constint& from)
{//Notice that I implement the functions in the class definition
value = from;
}
int GetValue()
{
return(value);
}
~MyClass(){}
};
If you convert your MyStaticClass to a class with all inlined functions, it will be completely reusable without the need for a partner cpp file.