compilling C++ source code (class) error
please i try to compile the below code on ubuntu with g++ but i was getting an error message
(fig03_05.cpp:10: error: new types may not be defined in a return type fig03_05.cpp:10: note: (perhaps a semicolon is missing after the definition of ‘GradeBook’) fig03_05.cpp:32: error: two or more data types in declaration of ‘main’ ). #include <iostream> using std::cout; using std:: cin; using std::endl; #include <string> using std::string; using std::getline; class GradeBook { public: void setCourseName ( string name ) { courseName = name; } string getCourseName() { return courseName; } void displayMessage() { cout << "Welcome to the grae book for \n" << getCourseName() << endl; } private: string courseName; } int main() { string nameOfCourse; GradeBook myGradeBook; cout << "Initial course name is :" << myGradeBook.getCourseName() << endl; cout << "\nPlsease enter the course name" << endl; getline ( cin, nameOfCourse ); myGradeBook.setCourseName( nameOfCourse ); cout << endl; myGradeBook.displayMessage(); return 0; } any guide will be of help. thanks |
Quote:
Code tags: http://www.linuxquestions.org/questi...do=bbcode#code |
thanks.
|
You are welcome, use the code tags ALWAYS and mark your thread SOLVED, if you feel...top right of this page.
|
Code:
#include <iostream> |
:D I meant you could have EDITED your first post rather than making a new one for code tags.
Anyway, Welcome to LQ. |
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
|
Quote:
It would not be appropriate to add the ; by editing post #1. Since it was a big chunk of code and a tiny change, it would have been nice in post #5 to mention the fact that the correction was adding a ; rather than assume that anyone reading the thread would connect what you said in post #2 to the code in post #5. |
All times are GMT -5. The time now is 03:38 PM. |