Just something I was trying to do off of the top of my head.
I've looked it over dozens of times, and I can't seem to find what I did wrong. I think it has something to do with calling on the corn variable inside the class though.Code:#include <stdafx.h> #include <cmath> #include <cstdlib> #include <iostream> using namespace std; class vegetable{ public: int broccoli; int carrot; int bean; static int corn; int cauliflower; } int main() { char cornanswer; char Y = "Y"; cout << " Is " << vegetable::corn << "a vegetable?"; cout << "Say Y for yes and N for no"; cin >> cornanswer; if (cornanswer == Y) { cout << "YES!! You are very smart, it is a vegetable!"; } else { cout << "Wow, you are very stupid! That answer is wrong!"; } return 0; }
Build Errors.
Code:1>Mess.cpp(24): error C2628: 'vegetable' followed by 'int' is illegal (did you forget a ';'?) 1>Mess.cpp(25): error C3874: return type of 'main' should be 'int' instead of 'vegetable' 1>Mess.cpp(27): error C2440: 'initializing' : cannot convert from 'const char [2]' to 'char' 1> There is no context in which this conversion is possible 1>Mess.cpp(45): error C2440: 'return' : cannot convert from 'int' to 'vegetable' 1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called



LinkBack URL
About LinkBacks





