Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Incompatible Types?????

Status
Not open for further replies.

noaaprogrammer

Programmer
May 4, 2001
36
US
I have a structure called WAVE_DATA in my project. It is defined in a 'C' file. In that file, an instance of the structure is defined as 'wavdat'. I also have a global instance of this structure defined in a 'C++' file, named 'wp_wavdat'. I am trying to copy the contents of 'wavdat' into 'wp_wavdat' by using this line of code in the 'C' file :

wp_wavdat = wavdat;

This gives me the error:

error C2115: '=' : incompatible types

I have noticed that 'wp_wavdat' uses the '.' operator and 'wavdat' uses '->'. Does anyone know why this is happening and how to fix it?
 
Yeah, one must be a pointer to the structure (->) while the other is just a regular old object (.) Whichever one is the pointer (I'm assuming 'wp_wavdat' is) do something like this:

*wp_wavdat = &wavdat;

Keep in mind however that 'wp_wavdat' now points to the memory location 'wavdat' meaing that you do not have a copy of the object but instead you have another reference to it. They are one in the same now, which might not be desirable.

bitwise
 
If wp_wavdat uses (.) means what it is an instance but wavdat is a pointer because use ->. In this case you should
wp_wavdat = *wavdat; or
wavdat = &wp_wavdat;
By the way, why does the name of a pointer begin with wp_? John Fill
1c.bmp


ivfmd@mail.md
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top