1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
#include<iostream>
using namespace std;
#include<fstream>
/*class Box
{
private:
int height;
int width;
int x;
int y;
public:
Box(int, int, int, int);
Box();
void Initialize();
void Move();
void Resize();
void Set1(int init_height, int init_width);
void Set2(int init_x, int init_y);
void GetPosition();
void GetDimensions();
};*/
class String
{
private:
char data;
int size;
public:
String(char);
String();
void Set(char str1);
void Print();
};
/*Box::Box(int init_height, int init_width, int init_x, int init_y)
{
Set1( init_height, init_width);
Set2( init_x, init_y);
}
Box::Box()
{
Set1(0,0);
Set2(0,0);
}
void Box::Initialize()
{
cout << "The height is " << height<< endl;
cout << "The width is " << width << endl;
cout << "x is " << x << endl;
cout << "y is " << y << endl;
}
void Box::Move()
{
int new_x, new_y;
cout << "Enter x: ";
cin >> new_x;
cout << "Enter y: ";
cin >> new_y;
Set2(new_x, new_y);
}
void Box::Resize()
{
int new_height, new_width;
cout << "Enter height: ";
cin >> new_height;
cout << "Enter width: ";
cin >> new_width;
Set1(new_height, new_width);
}
void Box::Set1(int init_height, int init_width)
{
if( init_height < 0)
height= 0;
else
height= init_height;
if ( init_width < 0)
width= 0;
else
width= init_width;
}
void Box::Set2(int init_x, int init_y)
{
if( init_x < 0)
x= 0;
else
x= init_x;
if ( init_y < 0)
y= 0;
else
y= init_y;
}
void Box::GetPosition()
{
cout << "The new x is " << x << endl;
cout << "The new y is " << y << endl;
}
void Box::GetDimensions()
{
cout << "The new height is " << height << endl;
cout << "The new width is " << width << endl;
}*/
String::String(char str1)
{
Set(str1);
}
String::String()
{
Set(256);
}
void String::Set(char str1)
{
data= str1;
}
void String::Print();
{
cout << data << endl;
}
void main()
{
/*Box InitBox(100, 200, 50, 75);
InitBox.Initialize();
Box NewBox;
NewBox.Move();
NewBox.Resize();
NewBox.GetPosition();
NewBox.GetDimensions();*/
String NewString("Hello");
NewString.Print();
}
|