|
Mapping means:
to copy the same method mapping declaration to each class Cc1 ... Ccn
so
class Cc1:
{ ... list of M1() ...Mn()- mappings }
class Cc2:
{ ... list of M1() ...Mn() mappings }
....
class Ccn:
{ ... list of M1() ...Mn() mappings }
this is lot of code ...
isn´t there any way to say:
class Cc1..n - overload "the punch of M1...Mn defined in a common set"
layer in between does not work because:
- Cc1...Ccn is derived from Cb1...Cbn
- Cc_::M1() used some data of Cc_
|
|
|
|
|
Quote: - Cc1...Ccn is derived from Cb1...Cbn
- Cc_::M1() used some data of Cc_
I don't get that. Either the methods are identical or not. If they are identical then they access variables with identical names.
|
|
|
|
|
sorry its tricky but:
Cc1::M1() is identical to Cc2::M1() ...
the only "data" some Mi() uses is the "this" pointer
Cc1::M1() { code m1 }
Cc2::M1() { code m1 }
... etc..
Cc1::M3() { f_calculate(this); ... }
Cc2::M3() { f_calculate(this); ... }
...
|
|
|
|
|
Since Cc1::M1 is identical to Cc2::M1 , both Cc1 and Cc2 could inherit M1 from an intermediate class.
|
|
|
|
|
Problem is inheritance to base of Cc1 Cc2 etc
B<-Ca1<-Cb1<-Cc1
B<-Ca2<-Cb3<-Cc2
if I use an intermediate class e.g D and declare D:M1()
then following problem arises:
class B { virtual M1() };
class Ca1 : public B
class Cb1 : public Ca1
class D : { virtual M1() } ;
class Cc1: public Cb1 , public D
class Cc2 : public Cb2 , public D
...
if I call now x->M1() with x is a Cc1*
which method will be used? Does D::M1() overload B::M1(), what I like to have?
|
|
|
|
|
sorry its tricky but:
Cc1::M1() is identical to Cc2::M1() ...
the only "data" some Mi() uses is the "this" pointer
Cc1::M1() { code m1 }
Cc2::M1() { code m1 }
... etc..
Cc1::M3() { f_calculate(this); ... }
Cc2::M3() { f_calculate(this); ... }
...
modified 5-Jan-17 10:54am.
|
|
|
|
|
The code in that form usually had a function to push/pull the class or object into and back off a stream. You would know the process if you are familiar with C# as serialization.
Microsoft has provided a bit more support and safety doing in C++ with MFC and the DECLARE_SERIAL macro which is the same as your MACRO.
Serialization: Making a Serializable Class[^]
It's still pretty much done the same way, you should have two constructors on the objects one of which has no parameters?
Just look into the code and check if the serialization is still used?
In vino veritas
|
|
|
|
|
?? stream?
don´t understand because I don´t us a stream
but do ou mean, that these horrible MFC macros came up because of th same problem?
|
|
|
|
|
What is written looks very much like the way you do serialization in C++
Serialization - Wikipedia, the free encyclopedia[^]
Read the article there are a number of reasons why you may want to serialize code from transmission thru, time based processing thru to encryption protection of code.
You will note within the article they talk about C and C++ not having serialization but you can do it with a sort of standard form. Your code looks to me like that standard form. MFC has the same setup because it has serialized classes and even that is discussed in the wiki article.
Note MFC's main reason for serialization: "The technique is called differential execution. It is useful in the programming of user interfaces whose contents are time-varying — graphical objects can be created, removed, altered, or made to handle input events without necessarily having to write separate code to do those things."
You were saying you don't know why the original code was written like that and they won't let you change it. If you need the serialization it would indeed break the program if you write it a different way.
So I am suggesting you check if the code is indeed doing serialization. If it is and that serialization is still needed you can not change it even if you wanted to.
In vino veritas
modified 9-Jul-16 0:34am.
|
|
|
|
|
maybe I got now what you talk about
"Changing the class is not possible when transfered via serial... because of reconstruction is dependent of class structure"?
OK, this doesnt happen here, there is an extra struct that holds data to store and load.
What I know is, that the code was extended within years, adding more and more features to the software. The derived classes have more features and do some different calculations
e.g. B::M1() ... used in B, Ca1, Cb1 also Ca2, Cb2 ... ect is different to Cc1::M1(), Cc2::M1() ... etc.
|
|
|
|
|
an example:
We have animals, cats and dogs
class animal()
{
OpenMouth() ;
breath_in();
breath_out();
}
class cat() : public animal
{
play_with_wool();
}
class dog() : public animal
{
hunt_cats();
}
class mops1() : public dog
{
get_fat_and_fart()
}
class mops2() : public dog
{
get_fat()
}
class greyhound1() : public dog
{
run()
}
class specialdog() : public dog
{
run_fast()
}
now we want to extent _some_ dogs to know how to barf()
for barf() we need some unctions of animal() (not all)
barf() { breath_in(); OpenMouth(); dosomething(); }
How can we add barf() to some (eg. 20 different dogs, and also some wolfs) without changing parent class structure?
class greyhound1() : public dog
{
run()
barf();
}
class specialdog() : public dog
{
run_fast()
barf();
}
class greywolf() : public wolf
{
barf();
}
and next step: we have not only barf() we have 20 new extends for these aimals.
It would mean: add these 20 functions to each animal seperately?
|
|
|
|
|
If I understood the question, the best method is using macro at header in derived classes and implementation in those cpp side (these must be different right?).
|
|
|
|
|
yes, they are different or use one member in this functions that is diffrent.
The functions to add itself are same to all, but refer to prior defined methods, functions or class members
macros is the WORST madhog (method) ever.
I know this because im now in task to remove all these mass of macros (1 - 10 pages long)
not debugable, now intllisense, you wont find anything.
in addition the advantage of OOD /OOP has been destroyed with these macros because a lot of not used things were copied because the developer didn´t know whats in there anymore (stupid copying)
Ther must be a smarter better way, hopefully
|
|
|
|
|
In my (otherwise) high DPI aware MFC application, I use a ribbon bar as the primary interface. I've provided high resolution (48x48) image strips, but when displaying on a high DPI (4k) monitor, these are not used.
I know I can trap a message when the DPI changes, and use this to rescale UI items (I do this for a few owner drawn aspects already to increase the font size), is there any way I can force CMFCRibbonBar to use the High DPI images?
Thanks,
Paul
|
|
|
|
|
Can i somehow get Version of Internet Explorer with mfc?
Have anybody some code example?
|
|
|
|
|
|
Thank you. that helped me.
|
|
|
|
|
The Free Compiler package offered by Microsoft, appears not to include MFC. Any ideas as to get access to MFC.
Regards,
Bram
Bram van Kampen
|
|
|
|
|
Google is your friend: MFC MBCS DLL Add-on[^]
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
Thanks,
It only suggests what I should have done at Install Time!
Tried again
a five hour re- install did not offer this option!
Bram van Kampen
|
|
|
|
|
MFC is (and was) only included with full Visual Studio versions.
So you have to install a full version (e.g. the free Community version) if you need MFC support.
|
|
|
|
|
Well MFC is Crucial to me,
How do I do that.
Thanks,
Bram van Kampen
|
|
|
|
|
|
MFC is included in Visual Studio 2015 community edition which is free.
MFC and ATL[^]
You can create MFC or ATL programs with Visual Studio Community Edition or higher. If you do not select these components when you first install Visual Studio, you will be prompted to install them the first time you attempt to create or open an MFC or ATL project.
The link to download VS2015 community is right there for free.
Visual Studio Community 2015 with Update 3 - Free
Downloads | Visual Studio[^]
In vino veritas
|
|
|
|
|
Well Guys
Got It!! Took me a While
Thanks!
Now I have to learn the Interface!
Bram van Kampen
|
|
|
|