Hello everyone. I have this class that is giving me errors and I cannot figure out why, it seems pretty simple. Here is the code:
Code:
#include <iostream>
#include <string>
using namespace std;
class myString
{
int x;
public:
void set_value(int);
int display_x() { return x; }
}
void myString::set_value(int a) {
x = a;
}
int main() {
myString myStr;
myStr.set_value(22);
cout >> "Value: " + myStr.display_x();
system("Pause");
return 0;
}
And here is the error:
14 N:\USERS\bakewens\CS240\test2.cpp new types may not be defined in a return type
14 N:\USERS\bakewens\CS240\test2.cpp two or more data types in declaration of `set_value'
14 N:\USERS\bakewens\CS240\test2.cpp prototype for `myString myString::set_value(int)' does not match any in class `myString'
10 N:\USERS\bakewens\CS240\test2.cpp void myString::set_value(int)
14 N:\USERS\bakewens\CS240\test2.cpp `myString myString::set_value(int)' and `void myString::set_value(int)' cannot be overloaded
N:\USERS\bakewens\CS240\test2.cpp In function `int main()':
21 N:\USERS\bakewens\CS240\test2.cpp "))'
I'm not sure why I am getting these - I copied and pasted a very similar program that works just fine, and it looks almost exactly the same. Any ideas? Thanks!