مشاركات الملفات الشخصية الجديدة

بدي افضفض عن تعريف اللف و الدوران اللي عندي و اللي عملته قبل شوي
- كنت بسوي تمرين عن ال classes -
مطلوب مني اني اعمل كلاس ل company
فيها خاصيتين : name \ salary
فبدي استخدم two objects عشان اخزن اسمين و راتبين
و بعدين بدي اجمع الراتبين عشان اشوف الtotal
فأنا بكل تعقيد رحت عملت هيك :
أعتذر عشان حعرضلك خبيصة

#include <iostream>
using namespace std;

class Company
{
private:
int salary;
string name;
int total;

public:

void setValue()
{
cout<<"Enter your name ";
cin>>name;
cout<<"Enter your salary ";
cin>>salary;
}

void getName()
{
cout<<"Your name is : "<<name<<endl;

}

void getSalary()
{
cout<<"Your salary is : "<<salary<<endl;
}

void setTotal(Company x, Company y)
{
total=x.salary+y.salary;
}
void getTotal()
{
cout<<"Total of Salary is : "<<total<<endl;
}

};


int main()
{

Company obj1;
Company obj2;
Company obj3;
obj1.setValue();
obj2.setValue();
obj1.getName();
obj1.getSalary();
obj2.getName();
obj2.getSalary();
obj3.setTotal(obj1, obj2);
obj3.getTotal();

return 0;
}​

و انا كنت بقدر بكل بساطة أني أخلي ال getSalary ترجع قيمة , يعني اخليها تسوي return
و بعدين اجمعهم بالmain هيك :

cout<<obj1.getSalary()+obj2.getSalary<<endl;
ضيعت وقت عالفاضي حكمو6
و ضيعت وقتك عالفاضي اذا شفتي
كنت مقهورة و ابغى اخلص من الموضوع فجيت افضفض
اعذريني ضف1
أعلى أسفل