• Advertisement
Sign in to follow this  

error C2440: '=' : cannot convert from 'const char [2]' to 'char'

This topic is 4815 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I get this error: h:\CompSci1\calculater\Calculator.cpp(45): error C2440: '=' : cannot convert from 'const char [2]' to 'char' from this line of code: yesno = "Y"; it is declared as: char yesno;

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by RigidBody
Well as we are nitpicking grammar.


"We" weren't; the previous nitpick was about spelling.

Quote:
char yesno;

Is a definition, not a declaration. =P


Good attempt, but actually it is the other way around. To "declare" something is to say it exists; to "define" it is to say what it is. Thus this is the declaration; yesno = 'Y' would be a definition. Although, my understanding of the word "grammar" has nothing to do with the meanings of words...

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
Original post by RigidBody
Well as we are nitpicking grammar.


"We" weren't; the previous nitpick was about spelling.

Quote:
char yesno;

Is a definition, not a declaration. =P


Good attempt, but actually it is the other way around. To "declare" something is to say it exists; to "define" it is to say what it is. Thus this is the declaration; yesno = 'Y' would be a definition. Although, my understanding of the word "grammar" has nothing to do with the meanings of words...


You are incorrect.

extern char yesno;

is a declaration.

char yesno;

is a definition.

extern char yesno = 'a';

is a definition.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement