I am having a little trouble understanding how members work in C/C++ and am especially prone to accessing non static members. I am starting again from the beginning with C/C++. My question is what is the best way to construct a window so that I can access my member functions? For example, I have a class that I wrote in C and am able to get the main window operating. The problem I run into is when non static members gets involved and I provided example code with the different method to access my class. My class also shows where I tend to run into the problems when I create a class using the 1st model example. The second example where the class is derived corrects this problem. Just wondering why the methods can look exactly the same in solution explorer yet behave so differently and any suggestions on how to nail down this concept will be greatly appreciated?
.h
class PP2D
{
void aMethodHere(); // A non static member
public:
PP2D(HINSTANCE);
~PP2D(void); // OnDestroy
int WinMain();
static LRESULT CALLBACK WndProcedure(HWND, UINT, WPARAM, LPARAM);
WPARAM Run();
private:
//WNDCLASSEX wc;
HINSTANCE hInstance;
HWND hwnd;
MSG Msg;
LPCSTR className;
};
PP2D::PP2D(HINSTANCE anInstance)
{
hwnd = 0;
hInstance = anInstance;
className = "PP2D";
}
PP2D::~PP2D(void)
{
}
.cpp
/// Example 1 non static members are a curse?
int PP2D::WinMain()
{
}
// Example 2: non static members are happy or are now static members?
class MainWindow : public PP2D<MainWindow>
{
};
1. PP2D is a Derived Template when used in case 2. "template class derived"
2. I was not complaining about anything.
3. The problem I was asking about is the entry point of the application which isn't that difficult to understand. If you run the above code with a static cast you run into to problem 1. If you run the code in problem 2 with a static cast your members are happy.
4. If you don't understand what I am asking then why are you commenting? I asked for help with up to date methods of creating windows which is not a complaint. It's been a while since I've been in C++ and this is the beginners section.
> PP2D is a Derived Template when used in case 2. "template class derived"
So in case 2 you are not using the `PP2D' class that you've posted. ¿how is the PP2D class defined then?
> I was not complaining about anything.
wrong term on my part. I don't understand your issue, the problem in case 1.
> is the entry point of the application which isn't that difficult to understand
if you say so... ¿what's your problem with main()?
> If you run the above code
case 2 doesn't compile.
case 1 does not show how the class is being used.
nowhere is the static cast that you just mention.
I've got no idea what is the problem 1.