i have a small question

//question is in main >>>

#include <iostream>
using namespace std;
class Department {

private: int dno;

public:

Department(int); int getDno();

};

class Emp {

private: double salary; Department dept;

public:

Emp( double, int );

Department getDept();

};
int main()
{
Emp e1(2000,1)
//what to type here to access getDno() through e1??
return 0;
}
e1.getDept().getDno();
1. Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/

2.
//what to type here to access getDno() through e1??
e1.getDept().getDno()

e1.getDept() returns an unnamed temporary Department object, and then getDno() gets called on that object.
Last edited on
Just to point out what might be obvious...

The following functions have been declared but not defined. Each of these needs to have a body defining what they do. The implementations may be relatively trivial, but you must provide them.

Department::Department(int)
int Department::getDno()
Emp:::Emp(double, int)
Department Emp::getDept();

Topic archived. No new replies allowed.