473,388 Members | 1,524 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Pointers to classes and handles && Null pointer

6
Hi,

I have 3 classes one of them is Point the other is line and the last one is triangle
I'm trying to read the output of a mesh generator program.

When I create the points and set the points with a constructor ;
point::point(int listnumber,double x1, double y1,double z1)
{
x=x1;
y=y1;
z=z1;
plist=listnumber;
}
and then I define handles in line and triangle classes for point
like : point *ptrs[3]; in triangle and
point *ptrlinepoint[2]; in line class

and my constructors in line and triangle are

line::line(int linelist,point& pl11,point& pl12)
{ llist=linelist;
ptrlinepoint[0]=&pl11;
ptrlinepoint[1]=&pl12;
}

triangle::triangle(int trianglelist,point& rp1,point& rp2,point& rp3)
{
ptrs[0]=&rp1;
ptrs[1]=&rp2;
ptrs[2]=&rp3;
tlist=trianglelist;
}

when I set my triangles like
point *pp=new point [Npoint];

ppt[i]=triangle(i,ct[i],pp[temp_p1_list_number-1];
triangle *ppt=new triangle[NTriangle];// SET TRIANGLE//

ppt[i]=triangle(i,ct[i],[ppindex_of_first_point],pp[index_of_second_point],
pp[thirdpoint]);

and SET POINTS OF THE TRIANGLE EVERTHING IS OK.
AND WHEN I SET THE POINTS OF LINES THEN IT CHANGES EVERYTHING LIKE THE POINTS OF TRIANGLES
for (i=0;i<=Noflines-1;i++){
ppl[j]=line(j+1,pp[index_of_first_point],pp[index_of_second]);}
AFTER THIS WHEN I TRY TO READ THE POINTS IN TRIANGLE I SEE THAT THEY ARE CHANGED CAN SOMEBODG TELL ME WHAT COULD BE THE SOLUTION TO RECOVER THE POINTER MESS UP.
Sep 5 '06 #1
0 1629

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: bo | last post by:
And why and where one should use one vs. the other? Verbally, it seems like semantics to me--but obviously there is some actual difference that makes references different and or preferable over...
3
by: sathyashrayan | last post by:
The standard confirms that the following initialization of a struct struct node { --- --- } struct node var = {NULL};
42
by: junky_fellow | last post by:
Consider an implementation that doesn't use all bits 0 to represent a NULL pointer. Let the NULL pointer is represented by 0x12345678. On such an implementation, if the value of NULL pointer is...
72
by: Paminu | last post by:
In math this expression: (a < b) && (b < c) would be described as: a < b < c But why is it that in C these two expressions evaluate to something different for the same values of a, b and...
69
by: fieldfallow | last post by:
Hello all, Before stating my question, I should mention that I'm fairly new to C. Now, I attempted a small demo that prints out the values of C's numeric types, both uninitialised and after...
5
by: Angel Tsankov | last post by:
Does the standard define what happens when a NULL pointer is dereferenced? If so, where?
5
by: Felix Kater | last post by:
Hi, if I want to make sure that neither the pointer arg nor the value to which it points to is NULL: Is solution (a) safe -- or does it have to be like (b) ? Felix void f(int* p){ /* (a)...
3
by: sajohn | last post by:
I'm fairly new to c programming and am not very clear on pointers and handles. Currently, I'm writting a wrapper script and I need to interface with another application. I have decided that the...
15
by: khan | last post by:
Hi, I read that pointer representation can non-zero bit pattern, machine specific.Compiler when comes accross value '0' in pointer context, converts it to machine specific null pointer...
20
by: prashant.khade1623 | last post by:
I am not getting the exact idea. Can you please explain me with an example. Thanks
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.