| Charcoalman (28) | |
|
How do you call a pointer in a class TO the main ? | |
|
Last edited on
|
|
| Charcoalman (28) | |
| anyone | |
|
|
|
| TheIdeasMan (1757) | |
|
If you write a proper complete question - with an example maybe? Then you might get some answers. 9 / 12 words is too brief. | |
|
|
|
| Charcoalman (28) | |
| test | |
|
Last edited on
|
|
| Charcoalman (28) | |
| test | |
|
Last edited on
|
|
| TheIdeasMan (1757) | ||
|
sd is the list of shapes, ShapeTwoDD is an individual shape. Do you want to access the x values of the shapes in sd? To do this you need to dereference the iterator and call the GetX function. Or use the -> operator with the iterator directly.
Now for the organisation of your code. The normal situation is to have the class declaration in a header file, all the class function definitions in a .cpp file, then a file containing main(). This better than having 100's of lines of code in one file If you are using an IDE, you can use the class wizard to create the files, it creates skeleton of the code also. The IDE should be able to create function stubs in the .cpp file when you declare in the header file. Hop all goes well. | ||
|
|
||
| Stewbond (1843) | |||||
I'm not going to read 340 lines of code, but to answer your original question:
Wait... reading through some of the 340 lines of code I see that x is not a pointer or array. You've defined it as a plain old int on line 19. You need to define it as int* if you want it to be an array. A change like that will require some work for you to change all of the instances of x, to an array. In the constructor, allocate the arraysize for x with the new[] keyword.Your getX function would then look like:
| |||||
|
Last edited on
|
|||||