السلام عليكم ورحمة الله وبركاتة
لدي مشكلة في طريقة تعامل مع "dynamically in the parameteized constructor" الفقرة المظلل عليها .
وأذا كان فية أخطاء أخرى أيضاً بالكود أخبروني رجاءً .
هذا نَص السؤال :
#include <iostream>#include<string>using namespace std; class employee{ string name, ID, *name_of_pro; int age ; float salary ; public: employee(){};//defult employee ( string n,int ag, float sa , string &name_pro){ name=n; age=ag; salary=sa; name_of_pro= new string(name_pro) ;// Here } employee(const employee &ob) { *name_of_pro=*ob.name_of_pro; } ~employee(){} void set1 (string s ){ name=s; } void set2 (string d){ ID=d ;} void set3( int aa ){ age=aa;} void set4 (float s){ salary=s; } void set5( string na ){ name_of_pro=&na ;} void print(){ cout<<"The name is"<<name; cout<<"the id is "<<ID; cout<<"the salart is "<<salary; cout<<"the age is "<<age; for(int i=0; name_of_pro!='\0';i++){//Here cout<< "the name of project is "<< name_of_pro; } } void Calculatesalary (int tax, int payrate){ (salary=salary+( payrate*salary)-tax); }}; int main(){ int tax; int praraty; string name1, id ,namepro;int age1; float sla; employee obj; cout<<"enter your name ";cin>>name1 ; obj.set1(name1); cout<<"enter your id"; cin>>id; obj.set2(id); cout<<"enter your age ";cin>>age1; obj.set3(age1); cout<<"enter your salary";cin>>sla; obj.set4(sla); cout<<"enter your name of number your projects";cin>>namepro; obj.set5( namepro); //here cout<<"Enter your tax and payrate"; cin>>tax>>praraty; obj.Calculatesalary (tax,praraty);obj. print(); system("pause"); return 0; }