KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Why does the following code produce this error even though c is a struct and has public inheritance by default? struct c { protected: int i; public: c(int ii = 0) : i(ii) {} virtual c* fun(); }; c* c::fun() { cout << "in c"; return &c(); } class d : c { public: d() {} d* fun() { i = 9; cout << "in d" << '\t' << i; return &d(); } }; int main() { c *cc; d dd; cc = ⅆ cc->fun(); }
Tags (comma-separated)
Save Edits
Cancel