C++ programming

The ‘C’ programming language was originally developed for and implemented on the UNIX operating system, on a DEC PDP-11 by Dennis Ritchie. One of the best features of C is that it is not tied to any particular hardware or system.
 
I just took a look at the following:
http://saturnboy.com/2011/03/objective-c-good-bad-ugly/

That makes objective C sound pretty poor, compared with Java, .NET, C++.

I guess Apple have got programmers over a barrel.

That article is nearly 2 years old and most of those points are no longer valid.

I've only just begun to heavily invest in learning C++ (as opposed to just dabbling in it) as part of my final year degree, and while it's good at teaching you the fundamentals of memory efficiency and header files, I would not recommend it as a first language or for someone out of touch with programming.

I would look at C# IMO. It's easier to learn than Java (which I'm not particularly fond of anyway) and Visual Studio is easily one of the best IDEs out there.
 
Does anyone have any recommendations for books to learn C# with, in the same format as the C++ one I have? i.e. beginner, but to a certan extent complete. It's already proving useful, but I keep hearing C# is the one to go for, so I might switch earlier than I anticipated.
 
Anyone care to have a look at a bit of code and give some advice?

It's basically an example to convert Celcius to Kelvin, and handle some errors along the way.

The code is as below, but I can't get it to throw an Exception, so I can't get to see if it's catching it or not. Everything I type in appears to turns to a number and be processed by my little function. Any idea what I'm doing wrong, if anything? :confused:

error2c.png
 
Step through your code with a breakpoint. In visual studio click in the margin next to the line you want to start stepping from, then press F10 to skip to the next line.

Also, you are typing in non numbers when trying to break it, right? :D
 
A couple of things:

ctok is declared as returning a double but you are returning k which is an int. Why not just do:

Code:
double ctok( double c )
{
return ( c + 273.15 );
}

No need to create a temporary variable.

Your main function doesn't seem to have any {} around the whole thing. Does it actually compile?

The reason you can't get it to throw an exception is because you are doing simple things. The only thing that would cause your program to throw an exception would be if it ran out of memory trying to allocate one of your variables. However your program is so small and the variables are small that there is very little chance of that happening.

Edit: cin is converting everything to a double (by whatever means it can) which is why you aren't seeing any errors there.
 
Indeed, cin is creating a double, there is no way to break your program. Of course that doesn't ean your program is without error.
 
Back
Top Bottom