|
[Sponsors] |
March 4, 2008, 05:59 |
Dragos,
I did followed thr
|
#21 |
Senior Member
Kārlis Repsons
Join Date: Mar 2009
Location: Latvia
Posts: 111
Rep Power: 17 |
Dragos,
I did followed through code, but did you read previous posts - the thing is: when I try to declare my own base and derived class with operator= in base class, operator= isn't accessible for object of class deriv if there is no forwarding in deriv class's declaration. Can't see such forwarding in class GeometricBoundaryField (and others) - can you help? K. |
|
March 4, 2008, 09:59 |
Indeed you're right, and it wa
|
#22 |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Indeed you're right, and it was my mistake. I don't see why in your code it is possible to call int i = 10; d.se(i); but not int i = 10; d.operator=(10); nor int i = 10; d = i;
...promise to look into it! Dragos |
|
March 5, 2008, 08:47 |
Ok, I think I have an answer!
|
#23 | |
Senior Member
Dragos
Join Date: Mar 2009
Posts: 648
Rep Power: 20 |
Ok, I think I have an answer!
Among other free on-line c++ book, there is also Thinking in C++ by Bruce Eckel. It specifies, and I quote: Quote:
I've just tried it, and it works! I hope this is useful, Dragos |
||
March 5, 2008, 08:59 |
Thank you! I'll take a look at
|
#24 |
Senior Member
Kārlis Repsons
Join Date: Mar 2009
Location: Latvia
Posts: 111
Rep Power: 17 |
Thank you! I'll take a look at that book
|
|
May 19, 2008, 14:27 |
Hmm, may I ask about virtual f
|
#25 |
Senior Member
Kārlis Repsons
Join Date: Mar 2009
Location: Latvia
Posts: 111
Rep Power: 17 |
Hmm, may I ask about virtual functions and inheritance?
#include <iostream> using namespace std; class base1 { public: bool use(bool y) {return x(y);} virtual bool x(bool y) = 0; }; class base2 { public: bool x(bool y) {return !y;} }; class deriv: public base1, public base2 { // whatever }; int main( int c, char ** a) { deriv d; if (!d.use(1)) cout << "yes"; return 1; } But it is "no", because compiler output is: virtinh.cpp: In function 'int main(int, char**)': virtinh.cpp:26: error: cannot declare variable 'd' to be of abstract type 'deriv' virtinh.cpp:20: note: because the following virtual functions are pure within 'deriv': virtinh.cpp:9: note: virtual bool base1::x(bool) So is it impossible to "merge" an abstract class with definitions of virtual functions, that reside in another base class similarly to example below? |
|
May 19, 2008, 20:51 |
may be the pure virtual functi
|
#26 |
Senior Member
|
may be the pure virtual function "virtual bool x(bool y) = 0; " in class "base1" should be defined definitely.
Su Junwei |
|
May 20, 2008, 07:05 |
That is a whole point of my qu
|
#27 |
Senior Member
Kārlis Repsons
Join Date: Mar 2009
Location: Latvia
Posts: 111
Rep Power: 17 |
That is a whole point of my question, that virtual bool x(bool y) = 0; and I want it to be called from use(..) through deriv d!
|
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Question concerning VOF | Flora | FLUENT | 2 | July 9, 2007 10:50 |
question about LES | gino briganti | FLUENT | 3 | June 27, 2005 07:05 |
A question | zhhuang | Siemens | 0 | April 29, 2003 02:44 |
The question about Y+ | rambol | CFX | 2 | November 7, 2002 10:40 |
Another UDF question | Christian | FLUENT | 7 | July 23, 2002 05:19 |