I'm looking for a C++ book with exercices(solved),practice or something like "tips and trips of c++ language" cause I need to prepare for the exam.
If someone know's a kind of this book , pls reply.I searched google , but didnt found what i want

I am not very sure what you need there. Are you in need of some C++ tips and tricks, or a good book which you can buy from Amazon?

I need a book with tests, like : "Find the error in the code bellow",something like that . The c++ exam,i'll have to take, consists of trick questions , this is an example :

What's the error? .Describe it :

#include <iostream.h>
class B
{ int a;
B(int i=0) { a=i; }
int get_a(){ return a; } };
class D: protected B
{ public: D(int x=0): B(x) {}
int get_a() { return B::get_a(); } };
int main()
{ D d(-89);
cout<<d.get_a();
return 0;

I understood C++ pretty well , but our teacher makes some really really confusing exercices.That's why I need a book with this kind of exercices or a book about pitfalls in c++

I don't think anyone is dumb enough to write a book like that. Your best bet is simply to know the language well enough to figure out the problems. Or tell your teacher to learn the language well enough not to accidentally introduce errors so that the problems are easier. ;)

.I understood C++ pretty well ,.

I hope you are smart enough to realize the coding style of the code you posted is just awful. Here are some tips, although they should not be read as if they are written in stone. Pay attention to the indention, placement of braces and hints about spelling. Making your code more readable should be your next goal before doing anything else.

I hope you are smart enough to realize the coding style of the code you posted is just awful. Here are some tips, although they should not be read as if they are written in stone. Pay attention to the indention, placement of braces and hints about spelling. Making your code more readable should be your next goal before doing anything else.

Considering that it's an example of a tricked up exam problem, why assume otherwise?

Tricked up exam problems tend to look legitimate, not like entries to the IOCCC. It's safer to assume that the teacher who wrote that is an incompetent fool.

My teacher wrote that sample code , and yes,is bad formatted,but he's not so bad ; at class , he explaines very well and he's one of the few teachers who really knows about modern programming

I don't think anyone is dumb enough to write a book like that.

Well, I found someone who is : Yashavant P.Kanetkar
I have his book with Test your C skills(which is great), but i dont have the one with C++. I would buy it from amazon , but the shipment takes between 4-6 weeks :( , and the exam is in a few days.

How about googling around. There are websites (maybe) that could give you such awful problems for you to practice. *chuckles*

>he's one of the few teachers who really knows about modern programming
So why does he insist on using pre-standard C++? I mean, he's had over ten years to get with the program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.