Click here to Skip to main content
15,911,360 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Base and derived classes Pin
Mark Salsbery22-Jun-07 7:34
Mark Salsbery22-Jun-07 7:34 
AnswerRe: Base and derived classes Pin
David Crow22-Jun-07 8:56
David Crow22-Jun-07 8:56 
GeneralRe: Base and derived classes Pin
ForNow22-Jun-07 12:13
ForNow22-Jun-07 12:13 
GeneralRe: Base and derived classes Pin
David Crow30-Jun-07 8:26
David Crow30-Jun-07 8:26 
GeneralRe: Base and derived classes Pin
ForNow30-Jun-07 15:47
ForNow30-Jun-07 15:47 
QuestionDoes a CListCtrl accepts a member variable name in edit mode? Pin
Arris7422-Jun-07 5:37
Arris7422-Jun-07 5:37 
AnswerRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Mark Salsbery22-Jun-07 5:44
Mark Salsbery22-Jun-07 5:44 
GeneralRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Arris7422-Jun-07 7:40
Arris7422-Jun-07 7:40 
GeneralRe: Does a CListCtrl accepts a member variable name in edit mode? Pin
Mark Salsbery22-Jun-07 8:03
Mark Salsbery22-Jun-07 8:03 
Questionhow to get Unique ID of a device Pin
VC_RYK22-Jun-07 4:52
VC_RYK22-Jun-07 4:52 
QuestionApplication Hang Pin
cpp_prgmer22-Jun-07 4:18
cpp_prgmer22-Jun-07 4:18 
QuestionRe: Application Hang Pin
David Crow22-Jun-07 4:31
David Crow22-Jun-07 4:31 
AnswerRe: Application Hang Pin
cpp_prgmer24-Jun-07 19:00
cpp_prgmer24-Jun-07 19:00 
QuestionRe: Application Hang Pin
Hamid_RT22-Jun-07 4:34
Hamid_RT22-Jun-07 4:34 
AnswerRe: Application Hang Pin
Jonathan [Darka]22-Jun-07 4:54
professionalJonathan [Darka]22-Jun-07 4:54 
GeneralRe: Application Hang Pin
cpp_prgmer24-Jun-07 19:02
cpp_prgmer24-Jun-07 19:02 
GeneralRe: Application Hang Pin
cpp_prgmer25-Jun-07 0:45
cpp_prgmer25-Jun-07 0:45 
Questionphp.h header file missing Pin
Kiran Pinjala22-Jun-07 3:50
Kiran Pinjala22-Jun-07 3:50 
QuestionRe: php.h header file missing Pin
David Crow22-Jun-07 4:34
David Crow22-Jun-07 4:34 
Questionreturn value - destructor call? Pin
zqueezy22-Jun-07 2:45
zqueezy22-Jun-07 2:45 
AnswerRe: return value - destructor call? Pin
Iain Clarke, Warrior Programmer22-Jun-07 3:01
Iain Clarke, Warrior Programmer22-Jun-07 3:01 
GeneralRe: return value - destructor call? Pin
zqueezy22-Jun-07 3:12
zqueezy22-Jun-07 3:12 
GeneralRe: return value - destructor call? Pin
Iain Clarke, Warrior Programmer22-Jun-07 4:05
Iain Clarke, Warrior Programmer22-Jun-07 4:05 
The "extra" destructor you're getting is because you're being nice and elegant and writing a * operator, which (quite correctly) returns an instance (albeit a temporary one) on CMatrix.

If the constructor / destructor is "expensive", then you're going to have to do it a different way.

class CMatrix
{
public:
    ....
    BOOL Multiply (CMatrix const &lhs, CMatrix const &rhs)
    {
        if (!ValidToDoThisMaths (lhs, rhs))
            return FALSE;
        // Do gnarly maths here to multiply lhs & rhs and keep the results in this
        ....
        return TRUE;
    }
    ....
};

void main ()
{
    CMatrix A,B,C;
    
    A.Create (blah);   // <-- however you make them have something interesting in them
    B.Set (blah);

    // we'd like   C = A * B;   but that would mean expensive operations with temp matrix
    C.Multiply (A,B);

    C.DoStuff ();
}


Its less elegant, but it would solve your problem.

It would also lose the ability to do:
D = A * B * C

but frankly, matrices are enough of a pain to work with [ (n x m) * (m x n) etc ] that that's probably not a huge loss.

I hope that helped,

Iain.



AnswerRe: return value - destructor call? Pin
Nemanja Trifunovic22-Jun-07 3:03
Nemanja Trifunovic22-Jun-07 3:03 
GeneralRe: return value - destructor call? Pin
zqueezy22-Jun-07 3:24
zqueezy22-Jun-07 3:24 

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.