11

Possible Duplicate:
The Definitive C++ Book Guide and List

Basically I am from C, Embedded C field. After working for 5 years in this field, I would like to start C++. Now, I have started learning C++. But the class concept is not clicking in my head. Please suggest me how should I start class concept or some good and simple website where I can start C++ easily. And please suggest me some good C++ problems (websites where I can find some C++ exercises).

Dr. Gut
  • 2,053
  • 7
  • 26
Rasmi Ranjan Nayak
  • 11,510
  • 29
  • 82
  • 122

4 Answers4

5

Have a look at Definitive C++ Book Guide. Since you have a C background I'd recommend "Accelerated C++" by Koenig and Moo, because it shows code in Modern C++ ideoms from the start. this will probably help you focus on the differences between C and C++ and show you which parts of your C habits you will have to unlearn.

Community
  • 1
  • 1
Fabio Fracassi
  • 3,791
  • 1
  • 18
  • 17
2

If you want to learn C++, Stroustrups "The C++ language" is a very good starting point imo. Personally I also learned a lot from Scott Meyers "Effective C++" and "More Effective C++"

Also I think that, considering your embedded background, you might not only need to "learn the language" but also work on your understanding of Object Oriented Programming. I think one of the basic books in this field is Grady Booch's "Object Oriented Analysis and Design" and the "Gang of Four": Gamma/Helm/Johnson/Vlissides "Design Patterns" (although both books are written with a Java background)

MartinStettner
  • 28,719
  • 15
  • 79
  • 106
1

C++ is originally from c, this book may help you to understand c++: "Inside the C++ Object Model"

Proteas
  • 89
  • 5
  • "Basically I am from C, Embedded C field. After working for 5 yrs in this field, I would like to start C++." – Proteas Feb 10 '12 at 09:12
0

The concept of "Class" can be easily modeled thinking to a C struct containing data members and a pointer to a struct containing function pointers (the v-table), where all functions have a "hidden" parameter Class* this.

That said, if you are already familiar with struct, pointer and function pointers, classes are nothing "misterious".

Everything else is "art of usage" and is not itself related to the class concept itself but to how they can be arranged to have an effective maintainable code.

At this point you can

  • try yourself to code a C program designed tat way (noting complicated, just to get the clue) or
  • forget about C itself, and try understand how the concept should be used (rather then for what it technically is).

For the last point the Koenig and Moo "Accelerated C++" book can be a good starter: it does not consider C, but how C++ and it's library should be used, and -after going deeper and deeper in detail- show where those concepts come from.

Emilio Garavaglia
  • 20,229
  • 2
  • 46
  • 63
  • 1
    most of the *interesting* usages of a class are not to do with virtual functions at all, but relate to access control (private/public), operators and constructors/destructors. In other words, nothing like a C struct – jalf Feb 10 '12 at 09:32
  • @jalf: I agree, but *you cannot fly unless you leave the ground*. The OP asked something about what a class IS, your comment is about what it is FOR. I'm talking about the concept of "ground" and of the meaning of the verb "leave". After the OP understand that, you cant start speaking about the verb "fly" and about the "flight control system". Speaking about the "flight control system" to someone that doesn't know about the existence of airplanes is clueless. I understand all this can be opinalble, but dowvoting for opinable reasons is prejudice.- – Emilio Garavaglia Feb 10 '12 at 09:40
  • So you wouldn't describe an aircraft in terms of its ability to fly? I think the *purpose* of something is pretty essential in understanding it. We could talk about an aircraft as "a thing which can fly and carry passengers", or woulc describe it as "an oversized titanium cigar with a lot of seats inside and two flat bits of metal sticking out". If you want to understand classes, you need to think about what they are used for. A class allows you to define a new datatype, and it allows you to impose behavior on that datatype. ctors/dtorsare essential in doing that. Virtual functions are not. – jalf Feb 10 '12 at 09:48
  • @jalf: "you wouldn't describe an aircraft in terms of its ability to fly?". Not to people who never heard the word "fly". Virtual functions are essential to manage runtime polymorphism, that is what OOP is -by definition- about. C++ programmers are used to use classes to do otehr things (ctor / dtor, encapsulation etc.) but without polymorphism there is not "true" OOP, just "generic programming". But OOP is clearly mentioned by the OP. – Emilio Garavaglia Feb 10 '12 at 09:52
  • He mentions OOP, sure, but he *asks* about "the class concept". And honestly, I don't *want* to see so-called OOP code written by someone who didn't understand what classes are. (moreover, as far as I'm aware, without encapsulation and abstraction, it can't be "true" OOP either, so I'd say those aspects of classes are pretty important to mention) – jalf Feb 10 '12 at 10:02