3 Replies - 248 Views - Last Post: 11 October 2012 - 04:46 AM Rate Topic: -----

#1 sanuuu  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-October 12

error

Posted 08 October 2012 - 09:11 AM

#include<iostream.h>
#include<conio.h>
struct book
       {
		private:
			int bn;
			float bp;
			int pn;
		public:
			void read()
			{
				cout<<"Enter The Book No \n";
				cin>>bn;
				cout<<"Enter The Book Price \n";
				cin>>bp;
				cout<<"Enter The No Of Pages \n";
				cin>>pn;
			}
			void setv1()
			{
				bn=10;
				bp=20;
				pn=30;
			}
			void setv2(int a,float b,int c)
			{
				bn=a;
				bp=b;
				pn=c;
			}
			void display()
			{
				cout<<"Book No Is"<<bn<<"\n";
				cout<<"Book Price Is"<<bp<<"\n";
				cout<<"No Of Pages Is"<<pn<<"\n";
			}
			void main()
			{
				clrscr();
				book b1,b2;
				cout<<"Enter Book NO";
				cout<<"Enter Book Price";
				cout<<"No Of Pages";
				b1.read();
				b2.read();
				b1.display();
				b2.display();
				b1.setv1();
				getch();

			 }

i have an error in this program
"declaration termination incorrectly"
what can i do

This post has been edited by jimblumberg: 08 October 2012 - 09:22 AM
Reason for edit:: Added missing Code Tags, Please learn to use them.


Is This A Good Question/Topic? 0
  • +

Replies To: error

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1703
  • View blog
  • Posts: 3,261
  • Joined: 30-May 10

Re: error

Posted 08 October 2012 - 09:27 AM

You seem to be missing a brace, and main() is inside your struct.

Don't forget to declare it as int main when you've moved it.
Was This Post Helpful? 2
  • +
  • -

#3 jimblumberg  Icon User is online

  • member icon


Reputation: 4131
  • View blog
  • Posts: 12,844
  • Joined: 25-December 09

Re: error

Posted 08 October 2012 - 09:27 AM

In future please use code tags when posting code. Second if you have errors post the complete error messages exactly as they appear in your development environment. These error messages have important information embedded within them to aid in location and repair of the errors.

You have not properly terminated your class. Count your braces {} you should have a closing brace for every opening brace (Don't forget the semicolon after the closing brace of your class.)

Also the function main() must be defined to return an int and you should return an int from this function. And main() can not be inside any class or namespace. It must be in the global scope.
int main()
{
   return 0;
}




Jim
Was This Post Helpful? 1
  • +
  • -

#4 raghav.naganathan  Icon User is offline

  • Perfectly Squared ;)
  • member icon

Reputation: 408
  • View blog
  • Posts: 1,440
  • Joined: 14-September 12

Re: error

Posted 11 October 2012 - 04:46 AM

View PostSalem_c, on 08 October 2012 - 09:57 PM, said:

You seem to be missing a brace, and main() is inside your struct.

Don't forget to declare it as int main when you've moved it.


Coz if you don't, you will be doomed by Salem_c ( look at his gif :) )

regards,
Raghav
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1