Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi friends,

I stuck at one point. Please help me to resolve this.
I am passing a reference object to a function and after some calculation I am assigning the simple object value to reference object. Here I am getting error as

error C2582: 'operator =' function is unavailable in 'CMatroxAudioExtractor'

Both objects are of same class. One is reference and other one is simple.
Please tell me how to resolve this error.

Here is the code.

C++
HRESULT CMatroxWriter::ImportAIFFAudio(CMatroxAudioExtractor& matroxAudioExtractor)
{
         HRESULT hr = S_OK;
         CMatroxAudioExtractor obmatroxAudioExtractor(strVideoPath)

         if(bIsQTRefFile)
		matroxAudioExtractor = obmatroxAudioExtractor;

         return hr;
}
Posted
Comments
[no name] 10-Dec-13 8:02am    
Did you read the documentation for the error before jumping to a conclusion?
http://msdn.microsoft.com/en-us/library/aa983787(v=vs.71).aspx
Sergey Alexandrovich Kryukov 10-Dec-13 12:11pm    
There is no such concept, "simple object". :-)
—SA

The error message says it all: The CMatroxAudioExtractor class has no public assignement operator ("operator="), i.e. the designers of this class did not want that anybody assign another object directory to an object of this class. This can have several reasons, for example because the object is so complex that it would be a severe performance problem to copy another object to this one.

Take a look at the documentation of the CMatroxAudioExtractor class and look for member functions that allow you to modify the object in a way that suits your needs instead of replacing it with a new one.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Dec-13 12:12pm    
Sure, a 5.
—SA
nv3 10-Dec-13 13:11pm    
Thank you, Sergey.
You are not assigning 'an object to a reference'. You are calling the copy assignment operator[^], that, for a some reason (unknown to me) is unavailable (that is the compiler cannot generate for you).
If you need to 'assign a reference' then you should use a pointer (and, accordingly, change a bit your code).
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 10-Dec-13 12:12pm    
Sure, a 5.
—SA

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