non static members

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?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
.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>
{
};
> Example 1 non static members are a curse?
I don't understand what you are complaining about. If you've got a build error, then post it verbatim.

Also, when trying to exemplify something make sure that the example does show what you are intending.


> class MainWindow : public PP2D<MainWindow>
PP2D is not a template.
Last edited on
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.
Last edited on
> 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.

> If you don't understand what I am asking then why are you commenting?
I'm asking for clarification.
http://hwrnmnbsol.livejournal.com/148664.html
http://www.cplusplus.com/forum/articles/1295/
http://www.eelis.net/iso-c++/testcase.xhtml
Topic archived. No new replies allowed.