LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2011, 12:14 AM   #1
hakeemtunde
LQ Newbie
 
Registered: Sep 2010
Posts: 11

Rep: Reputation: 1
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
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-24-2011, 12:33 AM   #2
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
Quote:
Originally Posted by hakeemtunde View Post
fig03_05.cpp:10: note: (perhaps a semicolon is missing after the definition of ‘GradeBook’)
Read and understand your above error message and put your code in
Code tags: http://www.linuxquestions.org/questi...do=bbcode#code
 
2 members found this post helpful.
Old 02-24-2011, 12:43 AM   #3
hakeemtunde
LQ Newbie
 
Registered: Sep 2010
Posts: 11

Original Poster
Rep: Reputation: 1
thanks.
 
Old 02-24-2011, 12:45 AM   #4
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
You are welcome, use the code tags ALWAYS and mark your thread SOLVED, if you feel...top right of this page.
 
Old 02-24-2011, 12:47 AM   #5
hakeemtunde
LQ Newbie
 
Registered: Sep 2010
Posts: 11

Original Poster
Rep: Reputation: 1
Code:
#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;
}
 
0 members found this post helpful.
Old 02-24-2011, 12:50 AM   #6
Aquarius_Girl
Senior Member
 
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
I meant you could have EDITED your first post rather than making a new one for code tags.
Anyway, Welcome to LQ.
 
1 members found this post helpful.
Old 02-24-2011, 03:30 AM   #7
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Moved: This thread is more suitable in Programming and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 02-24-2011, 07:17 AM   #8
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Quote:
Originally Posted by Anisha Kaul View Post
I meant you could have EDITED your first post rather than making a new one for code tags.
Notice that the version in CODE tags in post #5 doesn't just add those tags to the version in post #1. It also adds the missing ; that was responsible for the original error (as you pointed out in post #2).

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.

Last edited by johnsfine; 02-24-2011 at 07:25 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Compilation error trying to sub-class a Qt QAction class, not sure why rstewart Programming 2 02-08-2011 11:45 AM
[SOLVED] kernel compilling-make module_install error Trishito Fedora 2 03-29-2010 12:36 PM
Error Class Code: 70. ndrea Linux - Newbie 1 01-24-2010 05:22 PM
Error with update2 Enterprise linux class code 70 jasee Red Hat 5 07-13-2007 10:10 AM
error after compilling kernel greklas Slackware 2 09-06-2004 01:53 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration