help in c++

nirvanasoul

Disciple
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class name
{
char nam[5];
public:
void input()
{
cout<<"Enter your name ";
gets(nam);
}
void show()
{
cout<<nam;
}
void main()
{
clrscr();
name b1;
b1.input();
b1.show();
getch();
}
}
Error: "deceleration terminated incorrectly"!

Help me

thankx in adv...
 
here's corrected program -

Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class name           //class declaration
{
 char nam[5];
  public:
  void input()
  {
  cout<<"Enter your name ";
  gets(nam);
  }
  void show()
  {
  cout<<nam;
  }
[B]};                    //end of class[/B]

void main()            //separate main function, you had written it within class, which is syntactically wrong
{
  clrscr();
  name b1;
  b1.input();
  b1.show();
  getch();
}

You just ended the class incorrectly i.e.

class name
{
.
.
.
} (you forgot semicolon here i.e. }; )

and included main function into class.
 
Back
Top