I need to add nomber that user defined it of opject to the class l mean the construct function in the firsr | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I need to add nomber that user defined it of opject to the class l mean the construct function in the firsr

if l have a class "student"contains some attribute such as name and other isesintal thing and l need to add an ...x...object(s) the ....x .... is a nombre of this opject that users can defined it what is the strategy that l should follow it . l use the cpp language

23rd Jun 2018, 6:11 PM
Omar Muhammad Nofal
Omar Muhammad Nofal - avatar
3 Answers
+ 4
class student { public: int x; /* some other code */ }; int main() { student s; cin>>s.x; } /*i think this the solution you want */
23rd Jun 2018, 8:36 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 4
just make it into an array
23rd Jun 2018, 9:35 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
0
the ..x.. is number of object in other words the x is nomber of (s1.s2.s3.....) that mean the user who say how many ....s.... are there by give the x value for examble x=3 we have three object (s1.s2.s3)
23rd Jun 2018, 9:15 PM
Omar Muhammad Nofal
Omar Muhammad Nofal - avatar