Welcome to Dream.In.Code
Become a C++ Expert!

Join 149,928 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,812 people online right now. Registration is fast and FREE... Join Now!




C++ Class

 
Reply to this topicStart new topic

C++ Class, Gtg two errors in Turboc++ Compiler

LVPerumal
3 Jan, 2008 - 01:00 PM
Post #1

New D.I.C Head
*

Joined: 17 Dec, 2007
Posts: 1


My Contributions
CODE
#include<iostream.h>
class person
{
char name[30];
int age;
public:
        public:
        void getdata(void);
        void display(void);
        };
void person::getdata(void)
{
  cout<<"Enter name: ";
  cin>>name;

cout<<"Enter age: ";
cin>>age;
}
void person::display(void)
{
cout<<"\nName: "<<name;
cout<<"\nAge: "<<age;
}
int main()
{
  person.p;
  p.getdata();
  p.display();
  return 0;
}

User is offlineProfile CardPM
+Quote Post

Jayman
RE: C++ Class
3 Jan, 2008 - 02:19 PM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,317



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
First off, please post your topics in the correct forums and use code.gif tags when posting your code.

Can you post the exact error messages that you are getting when you compile your program?
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: C++ Class
3 Jan, 2008 - 02:29 PM
Post #3

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,869



Thanked: 53 times
Dream Kudos: 550
My Contributions
person.p;

maybe try:

person p;

as the first line really has no meaning.

also note that you have public: twice in your class definition.
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 1/8/09 03:13PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month