|
Can inline functions be inherited? How?
|
|
|
|
|
I think you are talking about classes
Yes. inline functions can be inherited.
inline functions can be defined in two ways.
1) functions defined with class declarations are by default inline.
2) if you defined the function to be inline in cpp files then those functions cannot be accesed outside its visibility.
Best Regards
Raj
|
|
|
|
|
Hi all,
I have developed one small application in VC++ using Visual Studio
I am going to fix memory leakages occurred in my program in the following code
char *m_tmpChar;
m_tmpChar=new char[100];
m_tmpChar="0";
now when I am going to delete this object with delete [] m_tmpChar it is showing me error dialog saying that assertion failed _crtisvalidheappointer(pUserData)
anyone please help me to solve this problem????
|
|
|
|
|
You can't copy a char arry using =. You need to use strcpy for that purpose.
What you are doing here is storing the address of a new string in m_tmpChar. This memory was not allocated with new so you get a crash when you try to delete it.
|
|
|
|
|
char *m_tmpChar;
m_tmpChar=new char[100];
m_tmpChar="0";
delete [] m_tmpChar;
That's because you're making a fundamental mistake. m_tmpChar is not some magic string type - its a pointer to a character.
In line 2, you allocate a patch of memory big enough for 100 chars, and make m_tmpChar point there.
In line 3, you make that variable point to another patch of memory that holds the character '0' followed by a NULL. This might even be read only, depending on complier settings. In the process, you've forgotten where your recently allocated lump of 100 bytes was.
In line 4, you are asking delete to free the "0" patch of memory, which certainly wasn't created by new . As you are in debug mode, you are getting errors.
So you have 2 bugs - (a) deleting memory which wasn't created with new [giving you the fault], and (b) not deleting memory that *was* created by new [giving you the leak].
That was the long explanation. The short explanation:
Ask your teacher about strcpy , or read your lecture notes.
Pointers are one of those bits of learning that is really strange and bizarre, until it all clicks in your head. Then its just dangerous if you're not careful.
Iain.
|
|
|
|
|
This is my complete code
char *m_tmpChar;
CString temp = m_list.GetItemText(0);
m_tmpChar="1";
RegSetValueEx(hCurKey,"",NULL,REG_SZ,(unsigned char*)m_tmpChar,strlen(m_tmpChar)+1);
Now in the above code it shows me Linkage error
So can you please give me solution with strcpy function
Thanks again!!!!!!
|
|
|
|
|
Sorry one line is missing
char *m_tmpChar;
m_tmpChar=new char[100];
CString temp = m_list.GetItemText(0);
m_tmpChar="1";
RegSetValueEx(hCurKey,"",NULL,REG_SZ,(unsigned char*)m_tmpChar,strlen(m_tmpChar)+1);
|
|
|
|
|
For this code, you will get away with not using strcpy, but you will still have the buf when you come to delete m_tmpChar;
change m_tmpChar="1"; to strcpy (m_tmpChar, "1"); which will copy the fixed string 1null into your temporary buffer.
The RegSetValueEx call looks fine to me. If you are getting a linker error, then you need to see what function it it failing to link, find that, and see where it lives.
Iain.
|
|
|
|
|
Thank you so much sir!!!
Now I get solution for that error
Thanks again for your valuable time spent behind me
|
|
|
|
|
Hi, again I have a same problem for memory leakage
here I am using CFont class for setting my font but it gives me not perfect result at output
CFont* m_pBoldFont1;
m_pBoldFont1 = new CFont;
m_pBoldFont1->CreateFont(15,0,0,0,900,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,"Arial");
CString test;
test.SetFont(m_pBoldFont1);
test.SetWindowText("test Section");
how can i free memory for the object(m_pBoldFont1) of CFont from memory
the above code gives me memory leakage error and also when I free memory
with delete operator it will display my string not correctly.
So, can you please help me to solve above problem
Thanks in advance!!!
|
|
|
|
|
Um, CString doesn't have a SetFont method. Or a SetWindowText method. So your above code not only has a memory leak, it wouldn't compile. CString is just a handy holder for a bunch of characters all in a row.
I'm going to make a leap in the dark, and say you're confusing it with a Label in VB...
As for the other question...
You need to keep a copy of the font around.
class CMyDialog : public CDialog
{
public:
CDialog (.....)
{
m_fMyFont.CreateSomehow ();
.....
}
....
BOOL OnInitDialog ()
{
SetFont (&m_fMyFont);
....
return CDialog::OnInitDialog ();
}
protected:
CFont m_fMyFont;
};
Obviously, I've removed a lot of boilerplate code. I'm assuming you have a dialog, or such. Create the font, and SetFont with a pointer to it. In the above example, the window will be destroyed, then the destructor of CMyDialog. At the end of that, the destructor for CFont will be called, tidying up the font.
Not all solutions involve pointers!
Iain.
|
|
|
|
|
Hi,
Sorry it's not a CString but it is a CTransparentStatic this is which I have taken from Codeproject site.
So, it is like CTransparentStatic and all the methods are maintained in this file.
So, please give me solution if possible
Thanks!!!
|
|
|
|
|
Change the scope of your font variable.
In the class this code is from, you could:
Add a member variable CFont m_BoldFont1;
In the class' constructor, call CreateFont on the object.
m_BoldFont1.CreateFont(15,0,0,0,900,0,0,0,0,0,0,ANTIALIASED_QUALITY,0,"Arial");
Once the control is created, call SetFont on it using the member variable.
test.SetFont(&m_BoldFont1);
The object will be freed when the owner class destructor is called.
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
hii all...
I want to upload a document from my asp page the asp GUI contain a browse button and sourse and destination path.....
i want to know how can i upload a file from sourse to destination.....
what i am thinking...
i need to read the content and name of the file and then i nead to make a file on destination with same name and then write the content...
please help me....
Thanks in advance........
vikas da
|
|
|
|
|
Google for 'freeaspupload'
Regards
|
|
|
|
|
ahmad_ali wrote: Google for 'freeaspupload'
No i want to know the concept of uploading and downloading .....just like on gmail we can upload some file let it be a 5 mb word document.. when we upload this documet on gmail ... how it is uploded ... how can it be done in vc++....
Thanks
vikas da
vikas da
|
|
|
|
|
Google does not use VC++. It is asp/jsp/java/javascript.
Web browsers do normally not permit execution of VC++ generated binary code.
|
|
|
|
|
Hi all,
Can anybody explain me what is the meaning of all these "TCHAR ,BSTR and _bstr_t,_variant_t" and why and when we are using this in vc++...
Thanks
vikas da
vikas da
|
|
|
|
|
TCHAR is windows datatype, it will get converted to char or wchar depending on #define
BSTR is COM data type and is unicode compliant, it will always use the string in unicode format.
_bstr_t is also com data type and it encapsulates the BSTR data type.
_variant_t is VARIANT data type and can accept contain any datatype defined in union it has.
Atul
|
|
|
|
|
That is Really a case for "Read The Fine Manual". => http://msdn2.microsoft.com
Greetings from Germany
|
|
|
|
|
Hi all,
I am new to DirectShow so please help me with the problems that i am facing:
i am capturing video from some device like webcam.I have to encode the captured video using the wmv or mpeg-2 codec and then i have to tramsmit it on the network.All this i have to do using DirectShow.I have suceeded in capturing video but now i have to employ the codec to encode.Is DirectShow supports WMV or MPEG-2 codec to encode the video.If yes,then how can it be done.
Regards,
Mayank
|
|
|
|
|
DirectShow supports ASF files (WMV, WMA, etc) indirectly by using the Media Format SDK,
as documented here: DirectShow - Windows Media Applications[^]
The Media format SDK can be found here: Windows Media Downloads[^]
In the Media Format SDK, you'll find there's a network writer sink that you can use. Here's
an example of the documentation: Sending ASF Data Over a Network[^]
Since you're new to directShow, you probably have some studying to do so you understand how
to link DirectShow, which handles capturing and rendering, and the Media Format SDK, which handles
compression, decompression, and (limited) network communication. Hopefully these links will get
you started!
Have fun!
Mark
"Go that way, really fast. If something gets in your way, turn."
|
|
|
|
|
I have written a dll and exported classes.
I don't want to give header file to clients.
How this can be done. I want only to give lib file and dll to the user.
|
|
|
|
|
Why don't you want to provide header files ? It is always done this way...
|
|
|
|
|
As Cedric said, what's so bad about giving headers? One way or another, their code needs to know how to talk to yours, and the secret of all your dodgy function names will be revealed.
That said...
Some companies I use just distribute the DLLS. I then use #import to get the COM interfaces from those. But that is COM, and Typelibs, and all sorts of fun... Chances are its more headache than its worth, but it does let their DLLS be used from many languages, include VB. *I* don't care about that, but you might.
Iain.
|
|
|
|
|