Click here to Skip to main content
15,897,187 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDouble click event for custom tree control Pin
AnithaSubramani22-Nov-08 2:26
AnithaSubramani22-Nov-08 2:26 
AnswerRe: Double click event for custom tree control Pin
Randor 22-Nov-08 2:44
professional Randor 22-Nov-08 2:44 
AnswerRe: Double click event for custom tree control Pin
Rajesh Katalkar24-Nov-08 4:41
Rajesh Katalkar24-Nov-08 4:41 
QuestionHow to change the caption of AfxMessageBox () ? Pin
kapardhi22-Nov-08 1:54
kapardhi22-Nov-08 1:54 
AnswerRe: How to change the caption of AfxMessageBox () ? Pin
Randor 22-Nov-08 2:37
professional Randor 22-Nov-08 2:37 
AnswerRe: How to change the caption of AfxMessageBox () ? Pin
Graham Bradshaw23-Nov-08 2:43
Graham Bradshaw23-Nov-08 2:43 
QuestionInternet Connection Problem Pin
Dhiraj kumar Saini22-Nov-08 1:07
Dhiraj kumar Saini22-Nov-08 1:07 
Questionplease help on operators in matrix class Pin
Jorge22-Nov-08 0:35
Jorge22-Nov-08 0:35 
Hi, I am programming a simple matrix class with the following = and + operator definitions:

Matrix<T> Matrix<T>::operator=(Matrix<T> rhs)
{
    if (v!=NULL)
		delete [] (v);
	iRows=rhs.iRows;
    iCols=rhs.iCols;
	v=new T[iRows*iCols];
	for (int i=0;i<(iRows*iCols);i++)
			*(v+i)=*(rhs.v+i);
    return *this;
}


template <class T>
Matrix<T> Matrix<T>::operator+(Matrix<T>  rhs)
{

	Matrix<T> sum(iRows,iCols);
	if (iRows!=rhs.iRows || iCols!=rhs.iCols)
				throw Exception("Matrices dimensions do not match", __FILE__, __LINE__);
	else
	for (int i=0;i<(iRows*iCols);i++)
			 *(sum.v+i)=*(v+i)+*(rhs.v+i);
	return sum;

}


where

private:

    int iRows;
    int iCols;
    T* v;//Data structure


Now, I try the code: C=A+B,
The point is that before the return sum assings the sum value , the matrix variate sum is destroyed by the Matrix class destructor as it is a local scope variate, and I get a debug assertion error. On the other hand, if I comment the destructor code block, there code works fine.

Thanks in advance.

modified on Sunday, November 23, 2008 5:00 AM

QuestionRe: please help on operators in matrix class Pin
CPallini23-Nov-08 9:45
mveCPallini23-Nov-08 9:45 
AnswerRe: please help on operators in matrix class Pin
Jorge23-Nov-08 13:40
Jorge23-Nov-08 13:40 
QuestionHow to open .bmp file in paint in MFC? Pin
AnithaSubramani22-Nov-08 0:11
AnithaSubramani22-Nov-08 0:11 
AnswerRe: How to open .bmp file in paint in MFC? Pin
Randor 22-Nov-08 0:35
professional Randor 22-Nov-08 0:35 
AnswerRe: How to open .bmp file in paint in MFC? Pin
Code-o-mat22-Nov-08 0:38
Code-o-mat22-Nov-08 0:38 
AnswerRe: How to open .bmp file in paint in MFC? Pin
Hamid_RT22-Nov-08 2:19
Hamid_RT22-Nov-08 2:19 
GeneralRe: How to open .bmp file in paint in MFC? Pin
AnithaSubramani22-Nov-08 2:28
AnithaSubramani22-Nov-08 2:28 
GeneralRe: How to open .bmp file in paint in MFC? Pin
David Crow22-Nov-08 3:34
David Crow22-Nov-08 3:34 
GeneralRe: How to open .bmp file in paint in MFC? Pin
Hamid_RT22-Nov-08 20:30
Hamid_RT22-Nov-08 20:30 
QuestionHow can Release memory controls? Pin
Le@rner21-Nov-08 23:07
Le@rner21-Nov-08 23:07 
AnswerRe: How can Release memory controls? Pin
Randor 22-Nov-08 0:16
professional Randor 22-Nov-08 0:16 
Questionpascal to c code converstion .. Pin
Member 403833521-Nov-08 22:33
Member 403833521-Nov-08 22:33 
AnswerRe: pascal to c code converstion .. Pin
David Crow22-Nov-08 3:29
David Crow22-Nov-08 3:29 
GeneralRe: pascal to c code converstion .. Pin
Member 403833522-Nov-08 5:18
Member 403833522-Nov-08 5:18 
QuestionRe: pascal to c code converstion .. Pin
David Crow22-Nov-08 10:13
David Crow22-Nov-08 10:13 
AnswerRe: pascal to c code converstion .. Pin
Member 403833522-Nov-08 22:02
Member 403833522-Nov-08 22:02 
GeneralRe: pascal to c code converstion .. Pin
David Crow23-Nov-08 12:53
David Crow23-Nov-08 12:53 

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.