15 March, 2013


PASSING OBJECTS AS PARAMETERS IN C++

Today i learn very interesting concept that how to pass objects as parameters in C++.

Let’s explained with an example:

// class point

class point

{

protected:

int x,y, xStart, yStart, xEnd, yEnd;

public:

point()
{
}

point(int a, int b)
{
x=a;
y=b;
}

};

// class line

class line
{
public:

line()
{
}

line (point& pt1, point& pt2) // class passed by reference
{

xStart = pt1.x;

yStart = pt1.y;

xEnd = pt2.x;

yEnd = pt2.y;

cout<<xStart<<" \n " <<yStart<< "\n" <<xEnd << "\n" <<yEnd<< "\n" ;
}
};

int main()
{

point p1(2,4),p2(7,1);

line l(p1,p2);

return 0;

}

DXF_2D LIBRARY
Totally modified library files because i added the point entity.

Also added 5 layers.

Now it’s work like this

point p1(23,45), p2(34,67), p3(45.32,23.55);

// you can choose layer between 1 -5 ,here chooses 1 layer

line l(p1,p2,1,"line.dxf"); // create line line.dxf by passing two points p1 and p2.

line

/* create rectangle with two points

2 layer

1 for solid fill flag

color code 23 (1-256)

*/

rectangle room(p1,p2,2,"rect.dxf",1, 190);

rect

/* 3 layer

0 for pattern fill

pattern_name = "paisley"

color = 15

*/

rectangle bedroom(p1,p3,3,"bedroom.dxf",0,"ansi31",150);

bedroom

/* create circle

4 layer

1 for solid fill

color = 34

*/

circle c(p1,p2,4,"circle.dxf",1,50);

circle

/* 5 layer

0 for pattern fill

pattern_name

200 color code

*/

circle c1(p2,p3,5,"pattern.dxf",0,"paisley", 200);

pattern

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s