//Engr Ahmad Furqan Attari
//Chapter 6, Program 1
#include <iostream> //for input output
#include <conio.h> //for getch
using namespace std;
class Int
{
private:
int intvar;
public:
Int(): intvar(0)
{}
Int(int a):intvar(a)
{}
void show(void)
{
cout<<intvar;
}
void add(Int a,Int b)
{
intvar=a.intvar+b.intvar;
}
};
void main(void)
{
Int a(12),b=32,c;
c.add(a,b);
a.show();
cout<<'+';
b.show();
cout<<'=';
c.show();
getch();
}
//Chapter 6, Program 1
#include <iostream> //for input output
#include <conio.h> //for getch
using namespace std;
class Int
{
private:
int intvar;
public:
Int(): intvar(0)
{}
Int(int a):intvar(a)
{}
void show(void)
{
cout<<intvar;
}
void add(Int a,Int b)
{
intvar=a.intvar+b.intvar;
}
};
void main(void)
{
Int a(12),b=32,c;
c.add(a,b);
a.show();
cout<<'+';
b.show();
cout<<'=';
c.show();
getch();
}
A.O.A! Sir I am a student of Software Engineering 2nd Semester.I am working on a little project given as an assignment.Sir I want your help.I want to ask U
ReplyDelete1.Can we call a member function into another member function in class in OOP?I wrote a code for the project in which I need this process.If there exist a method for it I request U to tell me its syntax.
2.If there is a main menu in program and we open a sub menu.After checking it we want to go back into main menu what its procedure? PLZ help me.
Salaam
Delete1. Yes of course, we can call a member function from another in class and the syntax is same as for general functions, just call it.
2. There are a lot of methods to implement this. You can think of your own like
you can implement main menu in main function and sub menu in another function.
or if you have another idea, I can help you figure it out if you give some details
Regards:
Engr. Ahmad Furqan
A.O.A! Sir if you have solution of problems of chapter 9 Inheritance by Robert Lafore kindly uploaded.
ReplyDeletesoon
DeleteA.O.A! Sir Plz check this code.Compiler indicate 4 errors which I am not understanding.
ReplyDelete#include
#include
class circle
{
private:
int xc,yc,ra;
public:
circle(int x,int y,int r):xc(x),yc(y),ra(r)
{ }
void draw()
{
circle(xc,yc,ra);
}
};
void main()
{
clrscr();
int driver=DETECT,mode;
initgraph(&driver,&mode,"c:\\tc\\bgi\\");
circle c1,c2;
c1(10,15,10); //Error
c2(12,14,16); //Error
c1.draw(); //Error
c2.draw(); //Error
getch();
}
Plz check and help me by telling the solution of errors.
try changing the name of the class
Deletesince circle is also a function used to draw a circle
I also included header files.
ReplyDelete#include
#include
A.O.A! Sir plz check this code.
ReplyDelete#include
#include
void main()
{
clrscr();
int driver=DETECT,mode;
initgraph(&driver,&mode,"c:\\tc\\bgi\\");
triangle(10,11,12); //Error
getch();
}
compiler indicate error that function triangle should have a prototype which I am not understanding. Plz help.
this simply shows the triangle function is not defined before it is used.
Deleteu can use line function to draw three lines to make a triangle.
Sir, does setfillstyle function not work without floodfill function in graphics?
ReplyDeleteI wrote a code in which I used setfillstyle function to fill the circle but it did not fill the circle then I used floodfill function with setfillstyle then it fill the circle.
Hi!
Deleteas the name implies "setfillstyle" just sets the style in which you fill the shape, while floodfill actually fills in the shape.
So calling setfillstyle doesn't actually fills a shapte unless you call flootfill
Aoa Sir .... I want solution of his problem ........can you help me...?????
ReplyDeleteMake a Circle class. It has three attributes radius, the x and the y coordinates of its center.
Make a no argument constructor to initialize it’s attributes to 0, and a three argument constructor to initialize with the fixed values given by user.
Make void setValues(float, float, float) functions to set x, y and radius.
Make float area() function, and a float circumference() function to return area and circumference.
Make void print() function to display x , y coordinates and radius of a circle.
Call these functions in main() to test their working
sir i want splution of this problem.. can u help me.....????
ReplyDeletecreate a class that imitates part of the functionality of the basic data type int.Call the class int (not different spelling). the only data in this class is an int variable include member funtions to initialize an int to 0,to initialize it to an int value,to display it(it looks just like an int),and to add two int values.
can u help me...
ReplyDeleteAsslam o alaikum sir
ReplyDeleteSir can you please upload solution manual of Chapter#8