Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
std::vector <mtpoint2d> m_Points;

CArray < MtPoint2d , Mtpoint2d > m_Points


are both the above declartions are same?

if i give std::vector <mtpoint2d mtpoint2d=""> m_Points; as CArray its giving me error ...

Please let me know
Posted

The std::vector and the CArray are two different containers. They may server the same purpose, however they are not interchangeable (their public interface is different). If you can, use std::vector, since it is better.

[update]
You may alternatively use a
C++
CArray < MtPoint2d, MtPoint2d > 

or a
C++
std::vector < MtPoint2d > 


for the same purpose.
[/update]
 
Share this answer
 
v2
Comments
[no name] 20-Oct-15 2:56am    
std::vector m_Points;

CArray < MtPoint2d , Mtpoint2d > m_Points

both are same ? if i use one MtPoint2d in vector
CPallini 20-Oct-15 3:08am    
Yes, the vector takes just one template argument. See my update soution.
[no name] 20-Oct-15 2:56am    
thanks please let me kmow answer
[no name] 20-Oct-15 3:10am    
thanks
CPallini 20-Oct-15 3:41am    
You are welcome.
XML
CArray < class , class > point

Class A::A(const A &point2Array)
{

    point.Copy(point2Array.m_Points); //working with Carray

    how to do with vector
}



please let me know how to do with vector
 
Share this answer
 
Comments
CPallini 20-Oct-15 3:59am    
Let me say I find pointless such an operation, however, here we go:

std::vector< MtPoint2D > point;
class A::A(const A & other)
{
point.clear();
point.insert(point.begin(), other.m_Points.begin(), other.m_Points.end());
}
[no name] 20-Oct-15 4:33am    
thanks you very much
[no name] 20-Oct-15 5:20am    
add AP in CArray whats the equivalent API in vector for Adding is emplace-back . please let me know
[no name] 20-Oct-15 6:20am    
u there

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900