Places to begin learning C++ after perl, php ...

I have a long background with php and perl.

There are a few things that keep stopping me as I try to learn C/C++.

1 - Types : I dont get what types are what and for instance ... why cant my string be converted to a char ...

2- Pointers .. why does strVariableName not work but &strVariableName work?

Concepts, I guess, is what Im looking for.

Does anyone have any links to tutorials or books I can look into?

thanks so much!

A major difference between loosely typed languages like Perl and more strongly typed languages like C++ is that you have to be explicit when converting variables from one type to another.

So, you can't just do:

1
2
std::string foo = "1234";
int bar = foo;


You have to do something like:

1
2
std::string foo = "1234";
int bar = boost::lexical_cast<int>(foo);


People say it prevents coding errors. I think it introduces complexity which causes its own set of errors. That's because before Boost, you had to do:

1
2
3
4
std::string foo = "1234";
std::istringstream ss(foo);
int bar = 0;
ss >> bar;


Or use atoi() which ignores important errors that the average had no hope in detecting.

Probably the most important thing for a Perl programmer to learn about C++ is the type system, followed by the STL (containers and algorithms). This is a reasonable tutorial: http://www.mochima.com/tutorials/STL.html

You will likely have to use pointers at some point with C++. But try to get by with just value types and references.


take a book in C++ and start studying and practicing..
Learning basic C before C++ helps.

there are lots of good books available..
You can try some tutorials: http://www.cplusplus.com/doc/tutorial/
Topic archived. No new replies allowed.