classes, data, member function and objects

Jan 27, 2018 at 9:14am
Hi, just list down which one is classes,data,members function,and object no coding required. I just want to confirm my answer.

Observe the following program determine the output and answer the question below.
a.List down classes created
b.List all the data and members function of the class
c.List down object created
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class Employee{
 private:
         char name[40];
         float salary;
 public:
     void getData(){
       cout<<"Enter your name:\n";
       cin>>name;
       cout<<"Enter monthly salary:\n";
       cin>>salary;
     }
     void dispData(){
     cout<<name<<",Your yearly salary is"<<salary*12<<endl;
     }
 };
 void main()
 { 
       Employee q;
       q.getData();
       q.dispData();
     
      Employee r=q;
      r.dispData();
 }   
Jan 27, 2018 at 9:22am
You did not show your answer that we could confirm or refute.
Jan 27, 2018 at 9:29am
a. classes = Employee
b. data = name, salary[40]
members function= void getData(), void dispData(), q.getData(), q.dispData(), r. dispData()
c. object = Employee q, Employee r

is it correct??
Jan 27, 2018 at 12:29pm
Is there a difference in being a member and in the use of such member?
Jan 27, 2018 at 1:42pm
> Observe the following program

It is a badly formed (C++) program; it won't compile.
main() should have the return type int
To use the facilities of the standard library, the appropriate header must be included (#include <iostream>)
Use of unqualified names cout, cin and endl requires a using directive or using declarations.

Once these errors are fixed:

class: Employee

member variables of Employee: name (array of 40 char), salary (float)

member functions of Employee: getData ( void() ), dispData( void() )

named objects in main : q (Employee), r (Employee)

Note: We ignore all unnamed objects created by the program (for example the string literals used in the member functions). We also ignore the named objects which are brought in to the program by #include <iostream>
Jan 28, 2018 at 3:39am
thank you all!
Topic archived. No new replies allowed.