[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

new operator

Posted on 2000-04-27
7
Medium Priority
?
251 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
Suggested Courses

649 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