Home > Back-end >  Could you tell me why can't the output
Could you tell me why can't the output

Time:09-22



Compiled by the

# include & lt; Iostream>
using namespace std;
The class Array {
Int ar [2] [3].
Public:
Array () {}
Array (int [], [3] aa);
Void the show ()
{
For (int j=0; j<2; J++)
{the for (int I=0; i<3; I++)
{coutcout<'\ n';
}}
Array operator ^ (Array & amp;);
};
Array: : Array (int [], [3] aa)
{
Int I, j;
for(i=0; i<3; I++)
{
for(j=0; j<2; J++)
[j] [I]={ar aa [j] [I]; }
}
}
Array an Array: : operator ^ (Array & amp; C2)
{
Array c;
Int I, j;
for(i=0; i<3; I++)
{
For (j=0; j<2; J++)
[I] [j] {c.a. r=ar [I] [j]. ^ c2 ar [I] [j]; }
}
Return c.a. r;
}
Int main ()
{int I, j;
Int a [2] [3].
Int b [2] [3].
for(i=0; i<3; I++)
{
for(j=0; j<2; J++)
{cin> A, [I] [j]. }
}
for(i=0; i<3; I++)
{
for(j=0; j<2; J++)
{cin> B [I] [j]; }
}
Array A (A), B (B), C (A ^ B);
C.s. how ();
return 0;
}


CodePudding user response:

Array an Array: : operator ^ (Array & amp; C2)
This returns a temporary object, there will be a problem

CodePudding user response:

The
reference 1/f, Simple, Soft reply:
Array Array: : operator ^ (Array & amp; C2)
This returns a temporary object, there will be a problem of



Then how to solve?

CodePudding user response:

Add a copy constructor, and the operator=

CodePudding user response:

Returns a temporary object, return a temporary object reference only has a problem,,,,,,,
  • Related