Click here to Skip to main content
15,908,768 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionPlz Help : Urgent Pin
parims5-Sep-05 19:30
parims5-Sep-05 19:30 
AnswerRe: Plz Help : Urgent Pin
Vikrant for VC++5-Sep-05 20:06
Vikrant for VC++5-Sep-05 20:06 
AnswerRe: Plz Help : Urgent Pin
Marc Soleda5-Sep-05 20:27
Marc Soleda5-Sep-05 20:27 
GeneralRe: Plz Help : Urgent Pin
Marc Soleda5-Sep-05 20:47
Marc Soleda5-Sep-05 20:47 
AnswerRe: Plz Help : Urgent Pin
David Crow6-Sep-05 5:08
David Crow6-Sep-05 5:08 
QuestionAbout MS Access Database in vc++ Pin
parims5-Sep-05 19:28
parims5-Sep-05 19:28 
AnswerRe: About MS Access Database in vc++ Pin
Vikrant for VC++5-Sep-05 20:07
Vikrant for VC++5-Sep-05 20:07 
Questionwhy runtime error? what is difference? Pin
G Haranadh5-Sep-05 19:01
G Haranadh5-Sep-05 19:01 
#include < iostream.h >
#include < string.h >
class string
{
char *p;
int len;
public:
string(){ len =0; p=0; }
string(const char*s)
{
len = strlen(s);
p = new char[len+1];
strcpy(p,s);
}
string(const string &s)
{
len = s.len ;
p = new char[len+1];
strcpy(p,s.p);
}
~string() { delete p; }
friend string operator+(const string &s,const string &t);
friend void show(const string s);
};

string operator+(const string &s,const string &t)
{
string temp;
temp.len =s.len +t.len ;
temp.p = new char[temp.len +1];
strcpy(temp.p ,s.p);
strcat(temp.p ,t.p);
return temp;
}
void show(const string s)
{ cout << s.p; }

// if i wrote code like this. working fine.
int main()
{
string s1 = "new", s2 = "new1", s3 = "new2";
string t1(s1),t2(s2),t3(s1+s3);
cout<<"\n t1 = ";
show(t1);
cout<<"\n t2 = ";
show(t2);
cout<<"\n";
cout<<"\n t3 = ";
show(t3);
cout<<"\n \n= ";
return 0;
}

// if i wrote code like this. Not working.
// Getting Runtime error.
int main()
{
string s1 = "new", s2 = "new1", s3 = "new2";
string t1,t2,t3;
t1=s1;
t2=s2;
t3=s1+s3;

cout<<"\n t1 = ";
show(t1);
cout<<"\n t2 = ";
show(t2);
cout<<"\n";
cout<<"\n t3 = ";
show(t3);
cout<<"\n \n= ";
return 0;
}

Nice talking to you. Blush | :O
AnswerRe: why runtime error? what is difference? Pin
prasad_som5-Sep-05 19:27
prasad_som5-Sep-05 19:27 
AnswerRe: why runtime error? what is difference? Pin
Giannakakis Kostas5-Sep-05 20:06
professionalGiannakakis Kostas5-Sep-05 20:06 
GeneralRe: why runtime error? what is difference? Pin
G Haranadh5-Sep-05 21:04
G Haranadh5-Sep-05 21:04 
GeneralRe: why runtime error? what is difference? Pin
toxcct5-Sep-05 21:09
toxcct5-Sep-05 21:09 
QuestionClass wizard problem Pin
heavenode5-Sep-05 18:57
heavenode5-Sep-05 18:57 
AnswerRe: Class wizard problem Pin
MailtoGops5-Sep-05 22:01
MailtoGops5-Sep-05 22:01 
AnswerRe: Class wizard problem Pin
nguyenvhn5-Sep-05 22:18
nguyenvhn5-Sep-05 22:18 
AnswerRe: Class wizard problem Pin
heavenode5-Sep-05 22:24
heavenode5-Sep-05 22:24 
QuestionText data conversion into different file formats Pin
Member 3618575-Sep-05 18:49
Member 3618575-Sep-05 18:49 
QuestionHelp, error when deleting m_p in destructor. Pin
followait5-Sep-05 18:49
followait5-Sep-05 18:49 
AnswerRe: Help, error when deleting m_p in destructor. Pin
khan++5-Sep-05 19:03
khan++5-Sep-05 19:03 
GeneralIt's my careless, it should be delete[] p, but still have a error. Pin
followait5-Sep-05 19:33
followait5-Sep-05 19:33 
GeneralRe: It's my careless, it should be delete[] p, but still have a error. Pin
Jose Lamas Rios5-Sep-05 19:50
Jose Lamas Rios5-Sep-05 19:50 
AnswerRe: Help, error when deleting m_p in destructor. Pin
MailtoGops5-Sep-05 21:57
MailtoGops5-Sep-05 21:57 
AnswerThanks. Pin
followait5-Sep-05 22:56
followait5-Sep-05 22:56 
QuestionLPT Port programming in Win32(sdk) Pin
rohanr2p5-Sep-05 18:31
rohanr2p5-Sep-05 18:31 
AnswerRe: LPT Port programming in Win32(sdk) Pin
khan++5-Sep-05 18:57
khan++5-Sep-05 18:57 

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.