Click here to Skip to main content
15,914,608 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: RegEnumKeyEx and Windows XP Pin
22491713-Apr-05 1:54
22491713-Apr-05 1:54 
GeneralDifferent results using MT and MTd Pin
Pablo Fraile12-Apr-05 23:41
Pablo Fraile12-Apr-05 23:41 
GeneralRe: Different results using MT and MTd Pin
Member 796598513-Apr-05 1:14
Member 796598513-Apr-05 1:14 
GeneralRe: Different results using MT and MTd Pin
Pablo Fraile13-Apr-05 1:23
Pablo Fraile13-Apr-05 1:23 
Generaloverloading [ ] [ ] operator Pin
swati2412-Apr-05 23:34
swati2412-Apr-05 23:34 
GeneralRe: overloading [ ] [ ] operator Pin
toxcct13-Apr-05 0:46
toxcct13-Apr-05 0:46 
GeneralRe: overloading [ ] [ ] operator Pin
Cedric Moonen13-Apr-05 1:09
Cedric Moonen13-Apr-05 1:09 
GeneralRe: overloading [ ] [ ] operator Pin
Axter26-Apr-05 17:49
professionalAxter26-Apr-05 17:49 
There is no such thing as an operator[][].
However, you can simulate very easy.
All you have to do is create an operator[] that returns a pointer to your type.
inline T* operator[](int i) {return (m_data + (m_col*i));}

Here's a working example:
template < class T>
class dynamic_2d_array
{
public:
dynamic_2d_array(int row, int col):m_row(row),m_col(col), m_data((row!=0&&col!=0)?new T[row*col]:NULL){}
dynamic_2d_array(const dynamic_2d_array&src):m_row(src.m_row),m_col(src.m_col), m_data((src.m_row!=0&&src.m_col!=0)?new T[src.m_row*src.m_col]:NULL){
for(int r=0;r<m_row;++r)for(int c="0;c<m_col;++c)" (*this)[r][c]="src[r][c];
" }
="" ~dynamic_2d_array(){if(m_data)="" delete="" []m_data;}
="" inline="" t*="" operator[](int="" i)="" {return="" (m_data="" +="" (m_col*i));}
="" t="" const*const="" const="" (m_col*i));}
protected:
="" dynamic_2d_array&="" operator="(const" dynamic_2d_array&);
private:
="" int="" m_row;
="" m_col;
="" m_data;=""
};

you="" can="" download="" it="" from="" following="" link:
<a="" href="http://code.axter.com/dynamic_2d_array.h" rel="nofollow">http://code.axter.com/dynamic_2d_array.h[^]

Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
GeneralProblems with Custom controls in separate resource dll Pin
Gemini_II12-Apr-05 23:27
Gemini_II12-Apr-05 23:27 
GeneralRe: Problems with Custom controls in separate resource dll Pin
Member 796598513-Apr-05 1:10
Member 796598513-Apr-05 1:10 
GeneralProblem in loading metafile in VC++ MFC Pin
Sud_8312-Apr-05 23:16
Sud_8312-Apr-05 23:16 
GeneralRe: Problem in loading metafile in VC++ MFC Pin
Chris Losinger13-Apr-05 3:18
professionalChris Losinger13-Apr-05 3:18 
GeneralProblem with CListCtrl Pin
Neeranjan12-Apr-05 23:09
Neeranjan12-Apr-05 23:09 
QuestionHow to send a message from a object to its parents? Pin
thanh-hai.bui12-Apr-05 22:30
thanh-hai.bui12-Apr-05 22:30 
AnswerRe: How to send a message from a object to its parents? Pin
Joel Holdsworth12-Apr-05 22:54
Joel Holdsworth12-Apr-05 22:54 
GeneralRe: How to send a message from a object to its parents? Pin
thanh-hai.bui13-Apr-05 0:50
thanh-hai.bui13-Apr-05 0:50 
AnswerRe: How to send a message from a object to its parents? Pin
ThatsAlok12-Apr-05 23:01
ThatsAlok12-Apr-05 23:01 
GeneralConversion to LONGLONG Pin
fardak12-Apr-05 21:57
fardak12-Apr-05 21:57 
GeneralRe: Conversion to LONGLONG Pin
Joel Holdsworth12-Apr-05 22:17
Joel Holdsworth12-Apr-05 22:17 
GeneralRe: Conversion to LONGLONG Pin
fardak12-Apr-05 22:34
fardak12-Apr-05 22:34 
GeneralRe: Conversion to LONGLONG Pin
Joel Holdsworth12-Apr-05 22:44
Joel Holdsworth12-Apr-05 22:44 
GeneralRe: Conversion to LONGLONG Pin
fardak12-Apr-05 23:27
fardak12-Apr-05 23:27 
GeneralRe: Conversion to LONGLONG Pin
Joel Holdsworth12-Apr-05 23:39
Joel Holdsworth12-Apr-05 23:39 
GeneralRe: Conversion to LONGLONG Pin
fardak13-Apr-05 0:02
fardak13-Apr-05 0:02 
GeneralRe: Conversion to LONGLONG Pin
David Crow13-Apr-05 2:36
David Crow13-Apr-05 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.