Thread: Newbie Need help please

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    4

    Newbie Need help please

    We are learning about objects and I dont know why below program does not work....??? I copied it from the book. Pls help. Anyone interested in tutoring me?

    Code:
    #include <iostream.h>
    //using namespace std;

    class smalljob
    {
    private:
    int somedata;
    Public:
    void setdata(int d)
    {
    somedata =d;
    }

    void showdata()
    { cout <<"data is "<<somedata<<endl;}

    };

    int main()

    {
    smalljob s1, s2;

    s1.setdata(1066);
    s2.setdata(1776);

    s1.showdata();
    s2.showdata();

    return 0;
    }

    Code:
    #include <iostream.h>

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    You copied it wrong.
    Does the book say "Public:" or "public:"?

    gg

  3. #3
    Registered User
    Join Date
    Oct 2003
    Posts
    4

    Unhappy

    Oh man...this is so upsetting. I tried so many things. I even re-installed my compiler thinking that there was something wrong with it... thanks a lot.... I learned a lesson at a high price
    Thanks again

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM