Sign in to follow this  
ender_341

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

Recommended Posts

ender_341    136
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
Zahlman    1682
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
RigidBody    176
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this