|
You don't need to provide one for CByteArray if you provide one for DATAGRAM (that does not rely on CByteArray having a copy constructor)
|
|
|
|
|
Thanks toxcct and antlers,
toxcct was right that there in as far as I can see a way to provide a constructor for the struct, therefore I converted it to a class and used CByteArray's .Copy() to provide the assignment.
|
|
|
|
|
There is little difference between a class and a structure. The only difference is that the default protection is private for a class and public for a structure.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
that's what i was thinking, but in another side, i did never see struct with member functions...
so, here was my doubt.
TOXCCT >>> GEII power
|
|
|
|
|
Remember that a struct in C++ is a class that defaults to public access and a normal class defaults to private access. Since DATAGRAM has a dynamic member it does require a copy constructor:
struct DATAGRAM
{
CByteArray pkt_data;
DATAGRAM(DATAGRAM& dg)
{
pkt_data.Copy(dg.pkt_data);
}
};
Note: I did not use a typedef because it is not needed in C++.
Good Luck!
Now if the blasted power does not go out again, you'll get this message!
INTP
|
|
|
|
|
I recommend you use a more modern design of container, perhaps std::vector<unsigned char> . These containers provide a copy constructor so that the compiler default copy constructor for your class will work.
I don't think you should be having to work out how to copy a CByteArray efficiently, or even correctly.
Paul
|
|
|
|
|
I want to store listbox strings in to a file with serialization and load strings from this file with serialization.
Mehdi Hosseinpour
|
|
|
|
|
Something like:
CString str;
CFile file;
file.Open(..., CFile::modeWrite);
CArchive ar(&file, CArchive::store);
for (int x = 0; x < listbox.GetCount(); x++)
{
listbox.GetText(x, str);
ar << str;
}
ar.Close();
file.Close();
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Might want to ar << listbox.GetCount(); first.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Of course. I never indicated it was a complete working code example, hence the "Something like" qualifier. When typing this stuff from memory, small details often get omitted.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
Hi All.
The problem I am facing is a bit different. Even I do not know, whether the problem is related to Embedded programming or can be solved with VC++ MFC itself.
I want to send and recieve data between my vc++ application and a USB device. Thats the main issue.
Can anyone tell from where to start or if anyone can help me with the coding that should be done...I will be very thankfull for that help.
Thanks and regards,
Pankaj Bhalla
pankajbhalla@mantraonline.com
Pankaj Bhalla
Consultant - VC++
|
|
|
|
|
Which USB Device you are talking about.
Please Clarify.
|
|
|
|
|
Hello Darshan.
Thanks for your consideration and time. Actually, the USB device is itself, under the process of creation. So, not sure about the device, but if you can then please tell me general steps we have to take to make it possible. I mean the articles or any other source from where I can get more information about this issue. If you can the please tell me the MFC classes we can use or any info. about MFC and USB devices.
Thanks and Regards,
Pankaj Bhalla
|
|
|
|
|
Where can I download GDI+ librarys and headers?
|
|
|
|
|
You can get it from:
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/
I think it's in the core SDK part.
|
|
|
|
|
I've got a char array
<br />
char *vec;<br />
and i allocate memory for a number of elemets
<br />
vec = (char*) malloc ((sizeof(char))*(number_of_elemets));<br />
i do that in main.
then i call a free function
<br />
free_mem (vec);<br />
the function code is:
<br />
void free_mem (char *vec,number_of _elements)<br />
{ <br />
for (i=0;i<(number_of _elements);i++)<br />
{<br />
free (vec[i]);<br />
}<br />
}<br />
it gives me errors
what's wrong?
thanks!!
|
|
|
|
|
try this:
char *vec;
vec = new char[number_of_elements];
|
|
|
|
|
it's only ansi c, i can't use c++
|
|
|
|
|
I think you can just use free(vec), not free(vec[i]). Or maybe the error occurs because you forgot to pass the number_of_elements argument when you call free_mem?
|
|
|
|
|
Indrawati wrote:
I think you can just use free(vec) ...
Correct.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hello,
I compiled a program that reads the MAC-Adapter information and
therefore requires IPHLPAPI.DLL.
Now, on XPPro it's fine. DependencyWalker shows EFSADU.DLL to be
present in C:\windows\sytem32.
On XPHome, DependencyWalker shows this file as missing.
However, the program also runs on XP Home without any problems.
Now my question: Should I not care about the DependencyWalker warning
on XPHome? But then, why does this warning come up?
Could it be that DependencyWalker lists DLLs as missing although in reality they are never called (and therefore my app also works on XPHome)?
This is the dependency of the mentioned EFSADU.DLL:
IPHLPAP.DLL->MPRAPI.DLL->SETUPAPI.DLL->SHELL32.DLL->EFSADU.DLL
Thanks in advance for any help,
Tony
|
|
|
|
|
The Depends utility does not show DLLs that are explicitly linked. It only shows those that are implicitly linked.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
David,
thanks a lot for that information.
Do you know any way (or tool) that shows only explicitly linked
DLLs?
Thank you,
Tony
|
|
|
|
|