|
if you said of your info about C++ was better and what do you want to know exactly?
|
|
|
|
|
One of the founder of C/C++ wrote some really good books: Bjarne Stroustrup.
He really deserves to be read.
Also O'Reilly has undstanding books in every way.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: One of the founder of C/C++ wrote some really good books: Bjarne Stroustrup.
Dr. Stroustrup had nothing to do with C. Furthermore, he was not "one of the founders" of the language; he was the designer and original implementor of it.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
KarstenK wrote: "Stroustrup, in his own words, "invented C++..."
I never said he didn't.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
From where do you start?
Do you know programming but need to learn syntax and idioms of C++?
What language did you do before?
Are you just starting with programming as a whole?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
jhwurmbach wrote: Do you know programming but need to learn syntax and idioms of C++?
What language did you do before?
Are you just starting with programming as a whole
yes iam just starting with programming,
iam appointed as a trinee in VC++.
|
|
|
|
|
I am sorry, I only have books on C++ for someone who has at least *some* knowledge of programming.
That was where I started
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
Mr.Jhwurmbach me also not bad at programming..
but iam placed here as a fresher.ido't have fullpledged knowledge in VC++,upto my syllabus i know some basix of VC++.that iam asking u 2 Suggest books for improving my programming skills...
i hope u suggest some gud books for me
regards,
kp
|
|
|
|
|
I used
Nicolai M. Josuttis,"Object oriented Programming in C++", Addison-Wesley
Nicolai M. Josuttis,"The C++ standard library", Addison-Wesley
Richard M. Jones, "Introduction to MFC-programming with Visual C++", Prentice Hall
These are when you know all the basics, but before you developed a personal style:
Scott Myers, "Effective C++", Addison-Wesley
Scott Myers, "More Effective C++", Addison-Wesley
Scott Myers, "Effective STL, Addison-Wesley
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
thanQ Mr.Jhwurmbach
I do't have any particular tutor in this org for VC++ and iam the only person who selected for VC++.
so i have 2 prepare my own.
anyway iam thankful 2 u for suggestions.
and if possible pls suggest me some techniqs for self preparation in VC++.feel free 2 mail me kp007in@rediff.com
thanQ sir,
kp
|
|
|
|
|
krishna Vuppala wrote: I do't have any particular tutor in this org for VC++ and iam the only person who selected for VC++.
please look at this section of codeproject. http://www.codeproject.com/cpp . plus take my suggestion, please don't use SMS style language here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
krishna Vuppala wrote: me also not bad at programming..
Which contrasts with your earlier "iam just starting with programming" comment. Books are designed for a particular demographic/audience. If you claim no knowledge of programming, you will get one set of suggestions. If you claim some knowledge of programming, you will get another set of suggestions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have a base class with a virtual method, from this base there are multiple derived classes, but more than one needs to overide that virtual method.
class A{<br />
virtual void OnSth();<br />
}<br />
<br />
class B : public A<br />
{<br />
virtual void OnSth();<br />
}<br />
<br />
class C : public B<br />
{<br />
}<br />
<br />
class D : public C<br />
{<br />
virtual void OnSth();<br />
}
In the snippet above when class A calls OnSth() I need it to call the overide in both class B and class D . Everything I have tried only results in the class B 's method being called. What am I doing wrong?
Waldermort
|
|
|
|
|
WalderMort wrote: What am I doing wrong?
seems nothing.
Try to overide OnSth also in class C
void C::OnSth(){
B::OnSth();
}
Russell
|
|
|
|
|
WalderMort wrote: In the snippet above when class A calls OnSth() I need it to call the overide in both class B and class D.
I don't really understand that part of your question. Do you mean that when something outside your class calls the OnSth function, it should be redirected to D::OnSth (standard behavior of virtual functions) ?
Because if you call OnSth from inside class A, it cannot call both B::OnSth and D::OnSth, it will only call the function in the most derived class.
|
|
|
|
|
Cedric Moonen wrote: it will only call the function in the most derived class
yes, and that's his problem... D's method should be executed, but it's actually the method from B class that is called.
|
|
|
|
|
The problem was that the derived method in class D was not being called and instead calling that of class B.
I realise only one method may be called, but in reality I need both methods in classes B and D to be called. I suppose the only way to do this is to call B::OnSth() explicitly from class D or to add a new virtual method in class B.
The type of behaviour I'm looking for is when class A, internally, calls DoSth(), then the code should call the method in class B THEN call the method in class D. Not exactly C++ standard I know.
As for the main problem, I fixed it.
Waldermort
|
|
|
|
|
Perhaps this could be a design issue...
Basic OO design gives that a child class is a specialization of the base class and inherits the behavior of the base class. It's like saying "a rectangle is a shape" and shape would be the base class of rectangle. I guess you already know this.
But the implication is that when you derive from a class you also derive its behavior, i.e. the implementation of a certain method in case it's declared as virtual.
Calling a base class implementation of a method is quite alright, it just means that you want the behavior of the base class and want to add a little something to it.
From my understanding you want to go the other way around, i.e. calling the child class implementation from the base class and this creates some problems. Not that they cannot be solved, but there's a possibility that you're trying to solve the problem using the wrong tool.
Perhaps it's the observer design pattern[^] you really need. It's the same pattern used in the doc/view architecture when the document notifies all views about a change in the document.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: Perhaps it's the observer design pattern[^] you really need
That sounds like exactly what I am looking for. I have several windows, each represented by a class, that display certain aspects of a main class. When something changes in the base class, one or more windows may need to update their content.
After quick glance at a few articles relating to the topic, it seems a little difficult to implement. Guess I have some reading to do.
Thanks for pointing out this, new to me, design pattern.
Waldermort
|
|
|
|
|
WalderMort wrote: I have several windows, each represented by a class, that display certain aspects of a main class. When something changes in the base class, one or more windows may need to update their content.
Yep, that sounds like a school book situation for an observer pattern.
Perhaps you won't need to do a fully fledged implementation if you don't separate the data from the presentation: you could have a static list in the top-most class containing the "observers" and when the observers need to be notified you simply traverse the list calling the virtual "notify" method of each observer.
Just a thought... :->
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Sounds like a suitable solution, for now anyway.
Funny thing is I started off with a similar method, but used callback methods. I had to change from this because the more code I wrote, the more complicated it became trying to manage each instance.
Waldermort
|
|
|
|
|
A little further reading on the subject makes it all the more clearer.
It shouldn't be too much hassle to create a CSubject and CObserver containing only the virtual methods I need. Then it's a simple matter of deriving my existing code from these new classes, and have the observers call CSubject::HeyTellMeWhenSomethingChangesWillYa()
Waldermort
|
|
|
|
|
WalderMort wrote: It shouldn't be too much hassle to create a CSubject and CObserver containing only the virtual methods I need.
Nope.
WalderMort wrote: Then it's a simple matter of deriving my existing code from these new classes, and have the observers call CSubject::HeyTellMeWhenSomethingChangesWillYa()
Yes, and now that you strike me as empowered I really suggest you do it this way instead of a lazy shortcut like the one I suggested earlier , because in this case you would create reusable base classes that you can benefit from later. You will also get a clear understanding of the observer design pattern, which will also help you later since the pattern is quite common.
Go 'n get'em boy! Yiee-ha!
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: in this case you would create reusable base classes that you can benefit from later
I have to agree there, it's always useful to create re-usable code and add it to a common folder somewhere. I have got to the point now that I am re-using so much code, that I had to create a single header file just to #include my most used snippets.
As for this Subject Observer pattern. Most of the examples/articles I found simply pass a this pointer back to the observer through a single virtual method. In my eyes this is somewhat over the top, each observer wouldn't know what type of update or even if the update is relevent, but still have to call back to the subject to check what changed.
I took a different approach, much the same as you would normaly use virtual methods. I created a single base class, complete with a list of all virtual calls a class would need. This way the method can be over-ridden directly and whatever updated data is already there.
Infact I may even write an article on it. To think of all those projects where I could have used this, but instead took the far more complicated route of multiple derived types and callbacks...
Again, thanks for introducing this.
Waldermort
|
|
|
|