Solved

new operator

Posted on 2000-04-27
7
200 Views
Last Modified: 2010-04-02
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
Comment
Question by:mdanny
  • 4
  • 2
7 Comments
 
LVL 1

Author Comment

by:mdanny
ID: 2755705
Adjusted points from 10 to 20
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2756522
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
 

Accepted Solution

by:
sambitdash earned 20 total points
ID: 2807502
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:mdanny
ID: 2849183
Answer accepted
0
 
LVL 1

Author Comment

by:mdanny
ID: 2849184
the answer is
points= new CPoint*[2];

           
0
 
LVL 1

Expert Comment

by:ntdragon
ID: 2850424
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
 
LVL 1

Author Comment

by:mdanny
ID: 2853447
I can give you points also.I'll post a q for you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now