• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

new operator

What's the problem with this code???
CPoint **CMyDoc::GetTwoLastPoints()
{
 CPoint **points;
 *points=(CPoint*)new (CPoint*)[2];
 *points=(CPoint*)m_oblPoints.GetTail();
 //Code for second point...
 return points ;
}

//m_oblPoints is CObList
0
mdanny
Asked:
mdanny
  • 4
  • 2
1 Solution
 
mdannyAuthor Commented:
Adjusted points from 10 to 20
0
 
ntdragonCommented:
try then next

CPoint **CMyDoc::GetTwoLastPoints()
{
 CPoint **points;
 points= new (CPoint*)[2];
 points[0]=(CPoint*)m_oblPoints.GetTail();
 //Code for second point...
 return points ;
}

first:it should be
points= new (CPoint*)[2];

scond: it should be
points[0]=(CPoint*)m_oblPoints.GetTail
or
points[1]=(CPoint*)m_oblPoints.GetTail


0
 
sambitdashCommented:
CPoint **CMyDoc::GetTwoLastPoints()
  {
            CPoint **points;
            points= new (CPoint*)[2];

           // points should be first alloced memory before
          //  it's elements are assigned values else program
          //  will give memory fault

            points[0]=(CPoint*)m_oblPoints.GetTail();
            points[1]=(CPoint*)m_oblPoints.GetTail ();

            return points ;
}
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mdannyAuthor Commented:
Answer accepted
0
 
mdannyAuthor Commented:
the answer is
points= new CPoint*[2];

           
0
 
ntdragonCommented:
can i ask you why did you accepted his answer?
just for knowing i don't see much diffrence in his answer from my comment
0
 
mdannyAuthor Commented:
I can give you points also.I'll post a q for you
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now