In C ++, all I want to do is declare a class DisplayInfoin a file .h, and then in the file I .cppdo not need to enter the first DisplayInfo::DisplayInfo()and each function definition.
Unfortunately, I looked at more than 20 topics and my C ++ book for more than two hours and could not solve this problem. I think because I'm trying to use a 10 year Java training in C ++.
First test:
namespace DisplayInfoNamespace
{
Class DisplayInfo
{
public:
DisplayInfo();
float getWidth();
float getHeight();
...
};
}
using namespace DisplayInfoNamespace;
using namespace DisplayInfoNamespace::DisplayInfo
using DisplayInfoNamespace::DisplayInfo
{
DisplayInfo::DisplayInfo() {};
DisplayInfo::getWidth() {return DisplayInfo::width;}
...
}
For the second test, I tried to switch the order, so it was
class DisplayInfo
{
namespace DisplayInfoNamespace
{
...
}
}
And in the file .cpptry all of the above plus
using namespace DisplayInfo::DisplayInfoNamespace;
For the third test, I tried forwarding an ad with this heading:
namespace DisplayInfoNamespace
{
class DisplayInfo;
}
class DisplayInfo
{
public:
...all my methods and constructors...
};
VisualStudio2010 express , , .cpp , .
, , 30 , ++: " " ? ? ( , typedefs?)