1
Operating System / Re: Error
« on: November 24, 2013, 04:20:34 pm »No, i have not yet tried the steps given on that page and sorry for a bad topic name.No , ubuntu is not saved on HDD.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
1. Also I don't see any correct class usage. I think you are expecting the class members to pop up in global namespace.I didn't get you actually. I have used object to call the member functions of a class at the last in void main same as above told by you. Am i wrong? If yes then tell me the right method.
2. That is wrong. Correct class usage is - MyClass myInstance; create a instance of the class. Then you would access the member function like this myInstance.memberFunction.
i am using turbo c++
As for the error, I don't get the one you are talking about, what compiler are you using?
And yes, I fixed the "<*.h>" and "using * *;"
I tried compiling the program . Some of the errors were related to escape sequencing . Why would you do this ?I dont know about "using namespace std". I have never used . Can you please elaborate?
cout<<"\earth";
there is no \e escape sequence , a bunch of errors were like this .
Secondly
else(){} doesn't make sense to me
else if(){} is the correct way .
Third use#include <iosteam> not iostream.h
Fourth , use std::cout,std::endl,std::cin or "using namespace std;" before main .
Now I haven't run the program but it compiled properly , Nobody can help you with the inheritance problem or if the program behaves abnormally . You didn't mention what this program was supposed to do and what was the problem(after execution).
And p.s don't make a function inline when it is more than 3 lines of code , I see you've made a few functions inline which are like 30 lines long.
Oh god WHY!!!!!!, Please use [code ][/code ] tags and proper formatting...thanks..
#include<iostream.h>
#include<conio.h>
class A
{
public:
int fif,aud,ask,r,P;
void life1(); // lifeline declaration. when none of the lifeline is used.
};
void A::life1()
{
fif=0;
ask=0;
aud=0;
P=0;
cout<<"You have 3 lifelines:\n";
cout<<"Audience Poll\n";
cout<<"Computer Ask\n";
cout<<"Fifty fifty\n";
cin>>r;
if(r==1)
{
aud++; // get added when audience poll will be used.
}
if(r==2)
{
ask++;
}
if(r==3)
{
fif++;
}
P++; //get added by 1 when any one of them is used
}
class Ba : public A // when one from three of them is used.
{
public:
int t,O;
void life2a();
};
void Ba::life2a()
{
O=0;
cout<<"You have 2 lifelines:\n";
cout<<"Audience Poll\n";
cout<<"Fifty Fifty\n";
cin>>t;
if(t==1)
{
aud++;
}
if(t==2)
{
fif++; // get added when fifty-fifty will be used
}
O++; // get added by 1 when any one of them will be used.
}
class Bb : public A // when one from three of them is used
{
public:
int y,L;
void life2b();
};
void Bb:: life2b()
{
L=0;
cout<<"You have 2 lifelines:\n";
cout<<"Audience Poll\n";
cout<<"Computer Ask\n";
cin>>y;
if(y==1)
{
aud++;
}
if(y==2)
{
ask++;
}
L++;
}
class Bc: public A // when one from three of them is used
{
public:
int u,Y;
void life2c();
};
void Bc::life2c()
{
Y=0;
cout<<"You have 2 lifelines:\n";
cout<<"Computer Ask\n";
cout<<"Fifty-Fifty\n";
cin>>u;
if(u==1)
{
ask++;
}
if(u==2)
{
fif++;
}
Y++;
}
class Ca: public A // when only one lifeline left to use.
{
public:
int K;
void life3a();
};
void Ca::life3a()
{
K=0;
cout<<"You have only 1 lifeline:\n";
cout<<"Computer ask\n";
ask++;
K++;
}
class Cb: public A // when only one lifeline left to use.
{
public:
int J;
void life3b();
};
void Cb::life3b()
{
J=0;
cout<<"You have only 1 lifeline:\n";
cout<<"Fifty-Fifty\n";
fif++;
J++;
}
class Cc : public A // when only one lifeline left to use.
{
public:
int B;
void life3c();
};
void Cc::life3c()
{
B=0;
cout<<"You have only 1 lifeline:\n";
cout<<"Audience Poll\n";
aud++;
B++;
}
class ques
{
public:
int ans1,ans2,ans3;
char q,z;
void ques1()
{
cout<<"Which planet is called as REd planet ?\n";
cout<<"your options are :\n";
cout<<"1.Mars\n";
cout<<"2.jupiter\n";
cout<<"3.earth\n";
cout<<"4.uranus";
cout<<"\nif you want to use lifeline then enter y else n";
cin>>q;
if(q=='y'||q=='Y')
{
void life1();
{
if(r==1)
{
cout<<"1.80%\n";
cout<<"2.10%\n";
cout<<"3.6%\n";
cout<<"4.4%\n";
}
else if(r==2)
{
cout<<"Mars\n";
}
else (r==3)
{
cout<<"Mars /earth\n";
}
}
else
{
cout<<"Give an answer:\n";
cin>>ans1;
switch(ans1)
{
case 1:
cout<<"right answer\n";
break;
case 2:
cout<<"sorry your answer is wrong\n";
break;
case 3:
cout<<"sorry your answer is wrong\n";
break;
case 4:
cout<<"sorry your answer is wrong\n";
break;
}
if(ans1==1)
{
cout<<"You won Rs.1000\n"
}
}
}
void ques2()
{
cout<<"Your second ques is:\n";
cout<<"Light year is a unit of?";
cout<<"Your options are:\n intensity of light ";
cout<<"2. distance\n";
cout<<"3. time\n";
cout<<"4.planetary motion\n";
cout<<"\nif you want lifeline then press y else n:\n ";
cin>>z;
if(z=='y'||z=='Y')
{
if(P==1&&ask==1)
{
life2a();
if(t==1)
{
cout<<"\n1. 10%\t";
cout<<"2. 80%\t";
cout<<"3. 6%\t";
cout<<"4. 4%\n";
}
if(t==2)
{
cout<<"\ndistance\n/time\n";
}
}
else if(P==1&&aud==1)
{
life2c();
if(u==1)
{
cout<<"\ndistance\n/time\n";
}
if(u==2)
{
cout<<"distance\n";
}
}
else if(P==1&&fif==1)
{
life2b();
if(y==1)
{
cout<<"\n1. 10%\t";
cout<<"2. 80%\t";
cout<<"3. 6%\t";
cout<<"4. 4%\n";
}
if(y==2)
{
cout<<"distance\n";
}
}
else
{
life1();
if(r==1)
{
cout<<"1.10%\n";
cout<<"2.80%\n";
cout<<"3.6%\n" ;
cout<<"4.4%\n";
}
if(r==2)
{
cout<<"\ndistance\n/time \n";
}
if(r==3)
{
cout<<"\distance\n";
}
}
}
else
{
cout<<"Give ans:\n";
cin>>ans2;
switch(ans2)
{
case 1:
cout<<"sorry your answer is wrong\n";
break;
case 2:
cout<<" your answer is right\n";
break;
case 3:
cout<<"sorry your answer is wrong\n";
break;
case 4:
cout<<"sorry your answer is wrong\n";
break;
}
if(ans2==2)
{
cout<<"You won Rs.2000\n";
}
}
};
void main()
{
clrscr();
ques q;
q.ques1();
q.ques2();
getch();
}