Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Classes question. Not whole program. no int main! Write the implementation (

ID: 3834540 • Letter: C

Question

C++ Classes question. Not whole program. no int main!

Write the implementation (.cpp file) of the Acc2 class . The full specification of the class is: An data member named sum of type integer . A constructor that accepts no parameters . THe constructor initializes the data member sum to 0. A function named getSum that accepts no parameters and returns an integer . getSum returns the value of sum .

I got this and it said to use :: , tell me how to fix it

class Acc2 {

int sum;

Acc2() {
sum = 0;
}
int getSum() {
return sum;
}
};

Explanation / Answer

Hi,

Please find below the code with "::" scope resolution operator-

class Acc2 {

int sum;

Acc2() {
sum = 0;
}
int Acc2::getSum() {
return sum;
}
};