i want your help again in c++ !!
i want a function change the "int" to "string"
because in my project "Registration system" in task "b" i must write a course class which contains number of credits and a string id. In addition to the constructor, it should contain a print function..
and the id of course is seprate in 2 part "for example:cs201" thats why i need this function to convert the "int" part to "string" and i found the function sprint but i can not undarstand its work well !! so i want metod more easy than it or if you can explain to me how does it work ??
this my traying to solve
Expand|Select|Wrap|Line Numbers
- #include<iostream>
- #include<string>
- using namespace std;
- class course
- {
- private:
- int credits;
- string ID;
- static int serialid;
- public:
- course (int x, string y)
- {char a[10];
- sprint(a,"%d" ,serialid)
- ID= y+a;
- x= creadits;
- }
- void print()
- cout<<creadits;
- cout<<ID;
- }
- };
- course::serialid=1;