We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- C++
- Classes
- Classes and Objects
- Discussions
Classes and Objects
Classes and Objects
Sort by
recency
|
405 Discussions
|
Please Login in order to post a comment
Here's my question, why does looping with auto get random results? I used int scores[5] then in input and calculateTotalScore I used for (auto i: scores). I finally changed it to a for loop and it worked, but wasn't I technically doing the same thing??
Solution of the problem is:
Code solution:
include
include
include
include
include
using namespace std;
class Student{ public:
};
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */ int n; cin>>n; Student *st = new Student[n]; // int arr[3];
}
Wondering why in order to make an array of Student data type, we need the pointer of variable.
include
include
include
include
include
using namespace std;
class Student{
int total_students;
int fir, sec, thr, four, five; public: int totalscore; // void setTotal_stu(){ // cin>>total_students; // } // void getTotal_stu(){ // cout<>fir>>sec>>thr>>four>>five; } void getScore(){ cout< };
int main() { int totstu; cin>>totstu; Student obj[totstu]; for(int i=0;i