|
-
March 7th, 2006, 09:18 PM
#1
This is really lame...
Take a look at my code....
Code:
/*******************************************
FAMILY PROGRAM
PROGRAMMED BY GREG MARTIN
*******************************************/
/*******************************************
PREPROCESSOR DIRECTIVES
*******************************************/
#include <iostream>
#include <cstdlib>
#include <cstring>
using namespace std;
/*******************************************
GLOBAL DECLARATIONS
*******************************************/
enum moods {md_normal, md_happy, md_ecstatic, md_sad, md_mad, md_angry};
enum gender {gn_male, gn_female};
/*******************************************
PERSON CLASS DECLARATION
*******************************************/
class Person{
public:
//attributes
string myFullName;
string myTitle;
int myAge;
moods myCurrentMood;
gender myGender;
//method prototypes
int askAge() {return myAge;};
int askMood() {return myCurrentMood;};
int askGender() {return myGender;};
string askTitle() {return myTitle;};
string askName() {return myFullName;};
string speakToPerson(string targetPerson, string speechString);
void speakToSelf(string speechString);
};
/*******************************************
MAIN FUNCTION
*******************************************/
int main(){
//local variables
Person mom;
//set some attributes of the person we just created
mom.myFullName = "Kellie Johnson";
mom.myGender = gn_female;
mom.myTitle = "Mother";
mom.myAge = 38;
//output some information about the person we just created
cout << "We created a person." << endl;
cout << "This person's name is " << mom.myFullName << endl;
return 0;
}
This program isn't for anything special, I'm just bored.
The last cout statement in the main function is what my compiler is complaining about. Without it, it compiles nicely. With that statement in there, I get this error:
binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)
And then there are a bunch of nonsense function looking things after it but it only does this when the last cout statement in the main fuction is either commented or removed. Why is this? Does it have anything to do with my class declaration?
EDIT: NVM I FIXED THE PROBLEM.
Last edited by Ejaz; March 8th, 2006 at 06:16 AM.
Reason: Code tag added
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|