-
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>
-
You copied it wrong.
Does the book say "Public:" or "public:"?
gg
-
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:mad:
Thanks again