Click here to Skip to main content
15,917,795 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: diamond problem and virtual inheritance Pin
SandipG 22-Sep-08 21:37
SandipG 22-Sep-08 21:37 
GeneralRe: diamond problem and virtual inheritance Pin
George_George22-Sep-08 21:39
George_George22-Sep-08 21:39 
QuestionRe: diamond problem and virtual inheritance Pin
laksh220422-Sep-08 23:03
laksh220422-Sep-08 23:03 
QuestionIs there any memory leak in this code? Pin
SRKSHOME22-Sep-08 19:33
SRKSHOME22-Sep-08 19:33 
AnswerRe: Is there any memory leak in this code? Pin
User 21559722-Sep-08 19:53
User 21559722-Sep-08 19:53 
GeneralRe: Is there any memory leak in this code? Pin
SRKSHOME22-Sep-08 20:49
SRKSHOME22-Sep-08 20:49 
GeneralRe: Is there any memory leak in this code? Pin
User 21559722-Sep-08 21:46
User 21559722-Sep-08 21:46 
AnswerRe: Is there any memory leak in this code? Pin
Sarath C22-Sep-08 20:46
Sarath C22-Sep-08 20:46 
The program will be having memory leak, if you call set twice. You can rewrite the code better.

class test
{
	char* m_name;
public:
	test():m_name(NULL)
	{}
	void Set(const char* name)
	{
		// Leave the data untouched on invalid input
		if( name == NULL || 0 == strlen(name))
			return;

		if( m_name )
			delete []m_name;

		// Validate the pointer after allocating if necessary or put try/catch if exception enabled
		m_name = new char[strlen(name)+1]; 
		strcpy(m_name,name);
	}
	~test()
	{
		if( m_name ) 
                     delete [] m_name;
	}
	void display()
	{
		cout<<m_name<<endl;
	}
};


-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin

GeneralRe: Is there any memory leak in this code? Pin
SRKSHOME22-Sep-08 20:53
SRKSHOME22-Sep-08 20:53 
Questionproblem in copy .exe file Pin
vcprog22-Sep-08 18:56
vcprog22-Sep-08 18:56 
AnswerRe: problem in copy .exe file Pin
_AnsHUMAN_ 22-Sep-08 19:01
_AnsHUMAN_ 22-Sep-08 19:01 
GeneralRe: problem in copy .exe file Pin
vcprog22-Sep-08 19:22
vcprog22-Sep-08 19:22 
AnswerRe: problem in copy .exe file Pin
Hamid_RT22-Sep-08 19:34
Hamid_RT22-Sep-08 19:34 
GeneralRe: problem in copy .exe file Pin
vcprog22-Sep-08 19:38
vcprog22-Sep-08 19:38 
GeneralRe: problem in copy .exe file Pin
Mahesh Kulkarni22-Sep-08 19:49
Mahesh Kulkarni22-Sep-08 19:49 
GeneralRe: problem in copy .exe file Pin
Hamid_RT22-Sep-08 19:50
Hamid_RT22-Sep-08 19:50 
QuestionRe: problem in copy .exe file Pin
Rajesh R Subramanian22-Sep-08 19:44
professionalRajesh R Subramanian22-Sep-08 19:44 
AnswerRe: problem in copy .exe file Pin
vcprog22-Sep-08 19:47
vcprog22-Sep-08 19:47 
GeneralRe: problem in copy .exe file Pin
Rajesh R Subramanian22-Sep-08 19:56
professionalRajesh R Subramanian22-Sep-08 19:56 
GeneralRe: problem in copy .exe file Pin
vcprog22-Sep-08 20:19
vcprog22-Sep-08 20:19 
GeneralRe: problem in copy .exe file Pin
Hamid_RT22-Sep-08 20:43
Hamid_RT22-Sep-08 20:43 
GeneralRe: problem in copy .exe file Pin
Rajesh R Subramanian22-Sep-08 20:48
professionalRajesh R Subramanian22-Sep-08 20:48 
GeneralRe: problem in copy .exe file Pin
Hamid_RT22-Sep-08 21:34
Hamid_RT22-Sep-08 21:34 
GeneralRe: problem in copy .exe file Pin
vcprog24-Sep-08 0:57
vcprog24-Sep-08 0:57 
GeneralRe: problem in copy .exe file Pin
Rajesh R Subramanian24-Sep-08 1:23
professionalRajesh R Subramanian24-Sep-08 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.