Click here to Skip to main content
15,898,134 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Strings in the code Pin
Iain Clarke, Warrior Programmer7-Sep-09 21:03
Iain Clarke, Warrior Programmer7-Sep-09 21:03 
GeneralRe: Strings in the code Pin
Michael Schubert7-Sep-09 22:30
Michael Schubert7-Sep-09 22:30 
AnswerRe: Strings in the code Pin
CPallini7-Sep-09 21:10
mveCPallini7-Sep-09 21:10 
AnswerRe: Strings in the code Pin
Michael Schubert7-Sep-09 22:34
Michael Schubert7-Sep-09 22:34 
QuestionClosing of dialog box crashes application Pin
Le@rner7-Sep-09 18:12
Le@rner7-Sep-09 18:12 
AnswerRe: Closing of dialog box crashes application Pin
theCPkid7-Sep-09 18:31
theCPkid7-Sep-09 18:31 
GeneralRe: Closing of dialog box crashes application Pin
Le@rner7-Sep-09 18:34
Le@rner7-Sep-09 18:34 
QuestionSet the text of spincontrol( Updown control) using sendmessage Pin
Bedke7-Sep-09 18:07
Bedke7-Sep-09 18:07 
AnswerRe: Set the text of spincontrol( Updown control) using sendmessage Pin
Selvam R8-Sep-09 0:20
professionalSelvam R8-Sep-09 0:20 
GeneralRe: Set the text of spincontrol( Updown control) using sendmessage Pin
Bedke8-Sep-09 0:25
Bedke8-Sep-09 0:25 
QuestionSetWindowPos API doubt Pin
theCPkid7-Sep-09 15:47
theCPkid7-Sep-09 15:47 
AnswerRe: SetWindowPos API doubt Pin
«_Superman_»7-Sep-09 16:01
professional«_Superman_»7-Sep-09 16:01 
QuestionOverloading cast & assignment not enough for ==? Pin
dplong7-Sep-09 11:22
dplong7-Sep-09 11:22 
QuestionRe: Overloading cast & assignment not enough for ==? Pin
CPallini7-Sep-09 11:54
mveCPallini7-Sep-09 11:54 
AnswerRe: Overloading cast & assignment not enough for ==? Pin
dplong7-Sep-09 12:30
dplong7-Sep-09 12:30 
AnswerRe: Overloading cast & assignment not enough for ==? Pin
Stuart Dootson7-Sep-09 14:41
professionalStuart Dootson7-Sep-09 14:41 
Think you'll find it useful to add a Name constructor that takes a const char*. Reason is that C++ won't do 2 implicit conversions to get a function/operator to match - the 2 implicit conversions in this case being const char* -> string -> Name. That also permits operator== (which you will need to define - it's not one of the standard compiler provided operators) between a Name and a string literal:

#include <iostream>
#include <assert.h>

using namespace std;

class Name
{
public:
	Name(const char* t_) : t(t_) { }
	Name(const string& t_) : t(t_) { }
	Name() { }
	Name(const Name & t_) : t(t_.t) { }
	Name & operator=(const string & rhs) { t = rhs; return *this; }
	operator const string & () const { return t; }
	operator string & () { return t; }
private:
	string t;
};
bool operator==(const Name& left, const Name& right) { return string(left)==string(right); }

int main()
{
	Name n1 = "bananas", n2 = "bananas";
	assert(n1 == n2);	// Couldn't deduce template arg for string from Name
	assert(n1 == "bananas");	// No operator found for LH operand of type Name
} 

<div class="ForumSig">Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p</div>

QuestionRe: Overloading cast & assignment not enough for ==? [modified] Pin
dplong7-Sep-09 18:39
dplong7-Sep-09 18:39 
QuestionWhy do functions in the C library have short names? Pin
0x3c07-Sep-09 10:58
0x3c07-Sep-09 10:58 
AnswerRe: Why do functions in the C library have short names? Pin
CPallini7-Sep-09 11:13
mveCPallini7-Sep-09 11:13 
AnswerRe: Why do functions in the C library have short names? Pin
dplong7-Sep-09 11:32
dplong7-Sep-09 11:32 
AnswerRe: Why do functions in the C library have short names? Pin
Richard MacCutchan7-Sep-09 11:33
mveRichard MacCutchan7-Sep-09 11:33 
AnswerRe: Why do functions in the C library have short names? Pin
Stuart Dootson7-Sep-09 14:45
professionalStuart Dootson7-Sep-09 14:45 
QuestionID_FILE_NEW causes application crashed [modified] Pin
transoft7-Sep-09 10:58
transoft7-Sep-09 10:58 
AnswerRe: ID_FILE_NEW causes application crashed Pin
Richard MacCutchan7-Sep-09 11:36
mveRichard MacCutchan7-Sep-09 11:36 
GeneralRe: ID_FILE_NEW causes application crashed Pin
transoft7-Sep-09 16:58
transoft7-Sep-09 16:58 

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.