Invalid use of class in C++? -


Hi trying to pass some values ​​to a class but this does not tell me that this class 'image' 3 values ​​to send X, Y, Z and everything, but I should not try trying to do this ...

Here are the main CPP and functions that call the class

 for  (j = 0; j & lt; num_elems; j ++) {/ * hold and element from file * / vlist [j] = (verttex *) malloc (size (vertex) ); Ply_get_element (please, (void *) vlist [j]); Int vert = sprintf (szFile, "vertex:% g% g% g", vlist [j] -> x, vlist [j] -> y, vlist [j] - gt; z); Print top x, y, z for / * debugging * / TextAut (HDC, 600, J * 20, SFFile, Wirat); Drafting-> Figure (vlist [j] -> gt; vlist [j] - & gt; y, vlist [j] - & gt; z); }  

The error is here

  DrawFig-> Figure (vlist [j] -> gt; vlist [j] - & gt; y, vlist [ J] -> Z); }  

Here is WM_CREATE: Where do I start everything

  WM_CREATE case: HDC = Gate DC (HWND); // ShowWindow (g_hwndDlg, SW_SHOW); Hrc = wglCreateContext (HDC); WglMakeCurrent (HDC, HRC); G_hwndDlg = CreateDialog (HIN, MACNTIOUS1, HW & D, Dialog Process); Drafting = new image (1.0.1.0.1.0); InitGL (); break;  

Here is the picture H

  class shape {public: Figure (float x, float y, float z); Zero draw (); Float paramx () ​​{return x1; } Float parameter () {return y1; } Float promas () {return z1; } Conserved: Private: Float x1, y1, z1; List & lt; Figure & gt; M_vertices; };  

and here is Figure 0.6pp

  Figure: Figure (float x, float y, float z) {this-> x1 = x; This- & gt; Y1 = y; This- & gt; Z1 = z; M_vertices.push_back (Figure (x1, y1, z1)); } Zero Figure :: Draw () {List & lt; Figure & gt; :: iterator p = m_vertices.begin (); Gluclease (GL_Collo_B_BFFER_BIT | GL_DEPTH_BUFFER_BIT); GlLoadIdentity (); GluLookAt (0.0,0.0,4.0,0.0,0.0,0.0,0.0,1.0,0.0); GlColor3f (0.7f, 1.0f, 0.3f); GlBegin (GL_LINE_LOOP); While (p! = M_vertices.end ()) {glNormal3f (p-> Paramax (), P-> Paramy (), P-> Paraaj ()); GlVertex3f (p-> paramx (), p- & gt; paramy (), p-> paramz ()); P ++; } Glend (); }  

Any thoughts? It is using OpenGL, C ++ and IM codeboxes 10.05, just oh, yes it started in IH. Like DrawFig * figure;

The answer to @dark_charley is almost correct. Here's a better version that will actually work, but still is not what you want:

  class shape {// ... public: zero set (float x, float Y, float z); // ...}; Zero Figure :: Set (float x, float y, float z) {// your original code from constructor-> x1 = x; This- & gt; Y1 = y; This- & gt; Z1 = z; Figure: Figure (float x, float y, float z) {// call in constructor newly created set function set (X, Y, Z); M_vertices.push_back (Figure (x1, y1, z1)); } // Replace faulty line with: DrawFig-> set (vlist [j] -> gt; vix [j] -> y, vlist [j] - gt; z);  

Now, this is almost certainly not what you want. But it's also hard to know what you want. You have a design problem. The problem of design is that Figure has two responsibilities. It is a point in space, and a group of points describing a figure. This confusion of responsibilities is not able to fill your class in a special way to grow well.

You need two sections. You need a point class and a shape class. With the help of Figure square, you can define the location of the figures and you can also add points for the shape of the shape.

There is some big disturbance that something is wrong, this list & lt; Figure & gt; M_vertices; . It is very rare that in a class, perceptions are examples of yourself and usually when you do this, you are making your own data structure like a tree or a list and then in the class your own examples Pointers are included.

In addition to this, the fact is that due to the simple correction of @ Dark_charley, the infinite recapitalation is another big sign that something is wrong.

I'm guessing that this is a homework task, so all this help I will tell you that you already have a code I> Point class that you call Vertex Says.


Comments