ورود

نسخه کامل مشاهده نسخه کامل : كمك در ساخت Class به كمك C++



مرد مباح
06-06-2007, 09:28
سلام دوستان.

ميخواستم بدونم كه ساخت كلاس در c++ چطوريه و اگه ميشه يك نمونه مثال از ساخت يك كلاس با توابعش رو برام بزارين.
خيلي سپاس گزارم.

HAW3D
07-06-2007, 11:44
سلام
ای یه تکه سورس هستش که میاد یه آرایه رو میگیره و چا÷ میکنه که بوسیله کلاس هستش البته سازندهومخربو ... نداره
#include <iostream.h>
#include <conio.h>
int *arr;
class MyClass
**
public:
void print(int and)
**
for(int i=and-1;i>=0;i--)
**
cout<<"Number("<<i+1<<"):"<<arr[i]<<"\t";
}
}

int printB(int and)
**
if(and==-1)
return 0;
else
**
cout<<"Number("<<and+1<<"):"<<arr[and]<<"\t";
printB(and-1);
}

}

} ;

int main()
**
cout<<" \\|||/ "<<endl;
cout<<" (o o) "<<endl;
cout<<"---ooO(_)Ooo--- HaW3D"<<endl<<endl;

MyClass MC;
int and;
cout<<"Enter Andis of Array :";
cin>>and;
arr=new int[and];

for (int i=0;i<and;i++)
**
cout<<"Enter Number("<<i+1<<"):";
cin>>arr[i];
}
MC.printB(and-1);
getch();
return 0;
}